adammc
01-24-2007, 04:18 AM
Hi Guys,
Im using the code below to autofill a dropdown list from my MYSQL DB.
The only problem is it is leaving out the first entry (alphabetically) for each $vehicle_make ????
Does anyone know why this may be hapenning?
<select name="vehicle_model" class="textbox">
<option value="">select a type</option>
<?php
require_once ('../mysql_connect.php');
$query = mysql_query("SELECT model FROM Vehicles WHERE make='$_GET[vehicle_make]' ORDER BY model"); // autofill dropdown list 'select' with options from DB
$r = mysql_fetch_array($query);
while($r = mysql_fetch_assoc($query)) {
echo '<option value="'.$r['model'].'">'.$r['model'].'</option>';
}
?>
</select>
make='$_GET[vehicle_make]' An example of this data is (Honda, Ford, Toyota)
Im using the code below to autofill a dropdown list from my MYSQL DB.
The only problem is it is leaving out the first entry (alphabetically) for each $vehicle_make ????
Does anyone know why this may be hapenning?
<select name="vehicle_model" class="textbox">
<option value="">select a type</option>
<?php
require_once ('../mysql_connect.php');
$query = mysql_query("SELECT model FROM Vehicles WHERE make='$_GET[vehicle_make]' ORDER BY model"); // autofill dropdown list 'select' with options from DB
$r = mysql_fetch_array($query);
while($r = mysql_fetch_assoc($query)) {
echo '<option value="'.$r['model'].'">'.$r['model'].'</option>';
}
?>
</select>
make='$_GET[vehicle_make]' An example of this data is (Honda, Ford, Toyota)