note 21897 deleted from function.mysql-fetch-array by philip

From: Date: Sun, 08 Aug 2004 16:51:10 +0000
Subject: note 21897 deleted from function.mysql-fetch-array by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-74251@lists.php.net to get a copy of this message
Note Submitter: sirgoran@execpc.com ---- 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>

« previous php.notes (#74251) next »