I don't know if this will help, and it begs an answer from my earlier question. But here is an easy way to fill a drop-down (?) box with a mysql_query.
$sql="SELECT * FROM webl_players ORDER BY $sortby"; $result=mysql_query($sql,$db); print "<select name=\"canidate\">"; while($obj = mysql_fetch_object($result)) { print "<option>"; print "$obj->LastName, $obj->FirstName"; print "</option>"; } print "</select>"; ?> You will have to do some conditional stuff to get the right record to be automatically selected (<option selected>) But this might help Miles Thompson wrote: > Check the manual for the mysql_fetch_array() function, it shows you > how to extract data from $result. You will use the while loop (as > shown in the manual's example) to fill your combo box / selct list > /drop down menu, whatever we're calling that creature today. > > Miles > > At 12:45 PM 1/30/2002 -0600, Todd Williamsen wrote: > >> I am trying to get data from two columns, FirstName and Last name and >> displaying all the records LastName, FirstName in a drop down menu. >> >> The weird thing is that it only displays one record. I thought the >> table >> was hosed, but its not. I tried it through another database and still >> doesn't work. >> >> Here is the code: >> >> <? >> $db = mysql_connect($dbserver, $dbuser, $dbpass); >> mysql_select_db($dbname,$db); >> $sortby = "name ASC"; >> $sql="SELECT * FROM webl_players ORDER BY $sortby"; >> $result=mysql_query($sql,$db); >> $row = mysql_fetch_array($result); >> $FirstName = $row["FirstName"]; >> $LastName = $row["LastName"]; >> ?> >> >> <select name="canidate"> >> <option selected> >> <?php echo "$LastName, $FirstName"; ?> >> </option> >> >> I would list the whole page but its long! There is another SQL >> statement at >> the top of the page: >> >> <?php >> >> $db = mysql_connect($dbserver, $dbuser, $$dbpass); >> mysql_select_db($dbname, $db); >> $sql = "SELECT * FROM Canidate SORT BY 'LastName'"; >> $result = mysql_query($sql); >> ?> >> >> >> >> -- >> PHP Database Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]