Re: RE: newbie Dynamic Drop down lists using mysql
| From: | Sebastian | Date: | Fri, 04 Apr 2003 04:54:12 +0000 |
| Subject: | Re: RE: newbie Dynamic Drop down lists using mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142255@lists.php.net to get a copy of this message | ||
This is how i make my drop downs, see if this help...
echo "<form action=\"page.php\" method=\"get\">
<select name=\"category\">
<option value=\"-1\">show all";
$results = @mysql_query("SELECT * FROM table");
while($row = mysql_fetch_row($result)) {
echo "<option value=\"$row[0]\">$row[0]";
}
echo "</select><input type=\"submit\"
value=\"submit\"></form>";
cheers,
- Sebastian
-----Original Message-----
From: Bobby Rahman [mailto:bobby_rahman2002@hotmail.com]
| Hiya
|
| Im looking for any tutorials/snippets of code to show me how
| to code a
| dynamic drop down box/list in a php form.
|
| e.g a drop down menu of all current users (I assume this will need to
| connect to mysql db and select all usernames from table user
| and place in
| the menu.
|
| here what I have so far
| <?
| $connection = db_connect();
| $querystring = ("select username from user");
| $db_result = mysql_query($querystring);
|
| (if mysql_num_rows($db_result))
| {
| while ($row = mysql_fetch_row($db_result))
| {
| print("<option value=\"$row[0]\">$row[0]</option>");
| }
| }
| else
| {
| print("<option value=\"\">No users created yet</option>");
| }
|
|
| ?>
|
| Any URLS will be much appreciated.
|
| Thanks
|
| Bob