Reputation: 571
I'm trying to populate a select element with firstname and lastname values from a MySQL database.
At this point I have the code bringing back the data and inserting only one row into the select element and then displaying the remaining data below the select element.
I'm not sure why this is not inserting all of the data into an option tag - any and all help is appreciated, I read similar questions and could not figure this out.
(Correct Method to Populate a Select Element with MySQL data, as corrected by @FGraviton)
mysql_select_db("dustin",$con);
$sql="SELECT id,lastname,firstname FROM drivers_0135199";
$result=mysql_query($sql,$con);
echo "<select name='currentdrivers' id='currentdrivers'>";
while($row=mysql_fetch_array($result)){
echo "<option value=\"".$row['id']."\">".$row['lastname'].",".$row['firstname']."</option>\n";
}
echo "</select>";
Upvotes: 0
Views: 135