RE: [PHP-DB] foreach loop from MySQL select query to HTML select list

From: Date: Fri, 29 Nov 2002 06:25:05 +0000
Subject: RE: [PHP-DB] foreach loop from MySQL select query to HTML select list
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-23732@lists.php.net to get a copy of this message
At 10:40 AM 11/29/02 +1100, Gavin Amm wrote:
hmm, interesting to know the mysql_fetch_array() by default returns an array that's associative AND numeric - very useful to know & something i'll have to look into more, thanks Jason.
Using PHP's built in template system... $result_dept = mysql_query( "SELECT DepartmentID, Department
                             FROM Departments
                             ORDER BY Department" );
... <select name="dept"> <option>-select-</option> <? while( extract( mysql_fetch_array($result_dept, MYSQL_ASSOC))) : ?> <option value="<?=$DepartmentID?>"<?=$Department?></option> <? endwhile ?> </select> i do have one more problem though, i need to run the loop a 2nd time later
in the page in exactly the same way, but nothing is returned. i just copied & pasted the code from one section of the page to the next. do i need to reset one of the vaiables?
mysql_data_seek() http://www.php.net/manual/en/function.mysql-data-seek.php Rick

« previous php.db (#23732) next »