[thelist] PHP populate dropdowns.
Jack Guest
jguest at alconedigital.com
Fri Nov 29 06:29:00 CST 2002
Hi all!
I'm doing a quick questionnaire using PHP/MYSQL.
5 of the questions use the same drop down menu which is simply a list of names in a table.
How can I be most efficient in executing the query to get the names out and use them in the five questions? Here's the code i've got. This doesnt work because for each question I need to define a new $row variable - e.g $rowa, $rowb. Any ideas?
<?php include("inc_dbconnect.php");?>
<? $result = mysql_query("SELECT name FROM colleagues");?>
1) Who ?
<select name="colleagues1" size="1">
<?while ($row=mysql_fetch_row($result)){?>
<option value="<?echo $row[0];?>"><?echo $row[0];?></option>
<? }?></select>
2) Where ?
<select name="colleagues2" size="1">
<?while ($row=mysql_fetch_row($result)){?>
<option value="<?echo $row[0];?>"><?echo $row[0];?></option>
<? }?></select>
3) When ?
<select name="colleagues3" size="1">
<?while ($row=mysql_fetch_row($result)){?>
<option value="<?echo $row[0];?>"><?echo $row[0];?></option>
<? }?></select>
More information about the thelist
mailing list