View Single Post
Old 11-11-2010, 02:27 PM   #2 (permalink)
tony
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

mysql_fetch_array only returns the first row of the result and then moves the internal data pointer ahead. The array has 2 entries because 1 is for the numeric indexed array and the other one is for the associative array. what you can do is replace this:
php Code:
$dbarray = mysql_fetch_array($result);
to this
php Code:
$dbarray = array();
while($row = mysql_fetch_array($result)) {
    $dbarray[]=$row['PartNo'];
}
If the results are kinda big, it is better if you use mysql_fetch_row or mysql_fetch_assoc since mysql_fetch_array double the entries for numeric and associative.
From the manual:
mysql_fetch_row() - Get a result row as an enumerated array
mysql_fetch_array() - Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_assoc() - Fetch a result row as an associative array
mysql_fetch_object() - Fetch a result row as an object
tony is offline  
Reply With Quote
The Following User Says Thank You to tony For This Useful Post:
gj384 (11-11-2010)