Dynamically generate a drop down list

From: Date: Mon, 28 Jul 2003 16:20:24 +0000
Subject: Dynamically generate a drop down list
Groups: php.general 
Request: Send a blank email to php-general+get-157161@lists.php.net to get a copy of this message
Hi, I want to dynamically generate a drop down list of "authors" by querying a database. What I am doing at present is: function init_auth_list($auth_list) { $auth_list="<select name=author> <option value=\"\">select the name of t he author</option\>"; $query="select name from author order by name"; $result=pg_exec($GLOBALS["db"],$query); $numrows=pg_numrows($result); $i=0; while($i<$numrows) { $row=pg_fetch_row($result,$i); $auth_list=$auth_list."<option name=\"$row[0]\">$row[0]</option>"; $i++; } $auth_list=$auth_list."</select>"; return $auth_list; } and then I just echo $auth_list. Is it possible to have a function which echoes the values as they are read from the database? I tried doing something of this sort..but didn't work.. Any suggestions? Thanks in advance, Mukta

« previous php.general (#157161) next »