You will need to put the option tag in a loop to get all of the records in 
the table.

<select name="canidate"> (this can go anywhere but in while loop)

<?
$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);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
    $row = mysql_fetch_array($result);
    $FirstName = $row["FirstName"];
    $LastName = $row["LastName"];

    echo "<option value='$LastName, $FirstName'><?php echo '$LastName, 
$FirstName'?></option>";
    $i++;
}
?>

Also, without the value in the option tag, you will not be passing anything 
to the form.

HTH

Maureen Biorn


Todd Williamsen <[EMAIL PROTECTED]> said:

> 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 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]

Reply via email to