[thelist] PHP populate dropdowns.

David Bindel dbindel at austin.rr.com
Fri Nov 29 12:32:01 CST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I haven't tested it, but I think it should work.  Try this:

<? include("inc_dbconnect.php"); ?>
<?
$result = mysql_query("SELECT name FROM colleagues");

for ($i = 1; $i <= 5; $i++) {

	mysql_data_seek($result, 0);

	echo "<select name='colleagues$i'>";

	while ($row = mysql_fetch_row($result))
		echo "<option value='" . $row[0] . "'>" . $row[0] . "</option>";

	echo "</select>":
}
?>

I nested your code in a for loop and each time it goes through the
for loop, it sets the database pointer back to the first row.  That
way you can loop through the results several times (one for each
select menu).




HTH,

David Bindel

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPeeygn6TtTuKuQdTEQLhCgCfUxS6Atp7pmEsxL37vjQHOUBBqOkAn2UW
iItHuwRe5tSu4+9+lUmjPZdW
=EeF6
-----END PGP SIGNATURE-----




More information about the thelist mailing list