-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
just fixing something hehe
echo "<select name=\"cats\">"; $result = mysql_query("select * from cats order by title"); if ($result) { while ($c = mysql_fetch_array($result)) { echo "<option value=\"$c[id]\">$c[title]</option>"; } } echo "</select>";
André cerqueira wrote:
try:
echo "<select name=\"cats\">"; $result = mysql_query("select * from cats order by title"); while ($c = mysql_fetch_array($result)) { echo "<option value=\"$c[id]\">$c[title]</option>"; } echo "</select>";
Verdon Vaillancourt wrote:
I'm not sure I phrased my subject well, but...
The following is just to build a select menu from a table query result set.
It sort of works, but doesn't return the first row in the result set, ie if
I have the following rows in the table 'cats';
id title ========== 1 Pears 2 Oranges 3 Apples 4 Bananas
echo "<select name=\"cats\">"; $result = mysql_query("select * from cats order by title"); $categories = mysql_fetch_array($result); if ($categories) { while ($c = mysql_fetch_array($result)) { echo "<option value=\"$c[id]\">$c[title]</option>"; } } echo "</select>";
The resulting select menu will only include Bananas, Oranges, Pears.
Am I missing something terribly obvious to one less newbie than me?
TIA, Verdon
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFAMAYCaxdA/5C8vH8RAsXOAKCl/DfLLO9tC+4nk4S5a0g1pgSVfwCeIsiG MOflQLGII4Aojg1qF4hHHn0= =RYbS -----END PGP SIGNATURE-----
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php