joviyach
06-22-2006, 12:39 AM
I am trying to populate a drop down menu of MySQL data using PHP and I have hit a snag. I think its probably something simple that a freah pair of eyes could pick out right away that I am just not seeing... For some reason only the "firstname" part of the data is populating in the drop down and I can't figure out why. When I try to make changes to the echo lines to correct this, nothing shows up including the "firstname" data. The code is below...
<?php
//connect to MySQL
$connect = mysql_connect("localhost","xxx","xxx") or
die ("Could not connect to database.");
//choose the database
mysql_select_db("clients");
//get data from MySQL database
$result = mysql_query('SELECT clientid, firstname, lastname FROM people')
or die (mysql_error());
//populate drop down menu with data from MySQL database
echo '<select name="clientlist">';
while ($row = mysql_fetch_assoc($result))
{
echo '<option value="' . $row['clientid'] . '">' . $row['firstname']. ' ' . $row['lasttname'] . '</option>';
}
echo '</select>';
?>
Thanks,
Jim
<?php
//connect to MySQL
$connect = mysql_connect("localhost","xxx","xxx") or
die ("Could not connect to database.");
//choose the database
mysql_select_db("clients");
//get data from MySQL database
$result = mysql_query('SELECT clientid, firstname, lastname FROM people')
or die (mysql_error());
//populate drop down menu with data from MySQL database
echo '<select name="clientlist">';
while ($row = mysql_fetch_assoc($result))
{
echo '<option value="' . $row['clientid'] . '">' . $row['firstname']. ' ' . $row['lasttname'] . '</option>';
}
echo '</select>';
?>
Thanks,
Jim