Drop down menu with PHP
| From: | The Image Builder | Date: | Mon, 05 Apr 2004 02:01:15 +0000 |
| Subject: | Drop down menu with PHP | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-33746@lists.php.net to get a copy of this message | ||
Hello,
I have code for a drop down menu that works fine. But, though I only want
the results from one row to fill the form, I want it to show 2 rows in the
drop down menu. Can I do that? I would appreciate your help. Here is what
I have now:
<? mysql_connect("localhost","user","password");
mysql_select_db("database");
$sql = "select distinct category from books ORDER BY category ASC";
$makes_result = mysql_query($sql);
print ("<select name=\"category\">\n");
print("<option selected value=\"\">Please select a
Category</option>\n");
while($row = mysql_fetch_row($makes_result))
{
print("<option value=\"$row[0]\">$row[0]</option>\n");
}
print("</select>"); ?>
Thanks in advance
Charles