note 21897 added to function.mysql-fetch-array
| From: | sirgoran at execpc dot com | Date: | Thu, 30 May 2002 19:31:31 +0000 |
| Subject: | note 21897 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31233@lists.php.net to get a copy of this message | ||
I have better luck using the following.
In the example row0 is a unique id number, row1 is the first name, row2 is the last name. You can
also then order the output by last name if you want the options in a specific order.
<select name="users">
<?
$openConn2db = mysql_connect( "yourhost" );
$db = mysql_select_db( 'yourdatabase', $openConn2db );
$query = "SELECT * FROM yourtable ";
$query_result_handle = mysql_query ($query);
$num_of_rows = mysql_num_rows ($query_result_handle) ;
for ($count = 1; $row = mysql_fetch_row ($query_result_handle); ++$count)
{
echo "<option value='".$row[0]."'>$row[1] $row[2]
</option>\n";
}
?>
</select>
--
http://www.php.net/manual/en/function.mysql-fetch-array.php
http://master.php.net/manage/user-notes.php?action=edit+21897
http://master.php.net/manage/user-notes.php?action=delete+21897
http://master.php.net/manage/user-notes.php?action=reject+21897