RE: [PHP-DB] Creating drop down lists
| From: | Bastien Koert | Date: | Sat, 10 Mar 2007 14:45:19 +0000 |
| Subject: | RE: [PHP-DB] Creating drop down lists | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-43240@lists.php.net to get a copy of this message | ||
close
$query = mysql_query("SELECT root FROM training");
echo "<form action=something.php method=POST><select name='Field'>";
if($mysql_num_rows($result)>0){
while ($r = mysql_fetch_array($query))
{
$user = $r["username"];
echo "<option value='$user'>$user</option>";
}
}
echo "</select>";
should load the data in the select.
To link select boxes, first you need to decide on a method:
1. ajax - fire an ochange event to do an ajax call to load the next select box
2. pass the other select box data down to a javascript array and let the choices from the first select choose which array gets loaded into the next select
hth
Bastien
From: Scott <sburcky@gmail.com> To: php-db@lists.php.net Subject: [PHP-DB] Creating drop down lists Date: Sat, 10 Mar 2007 04:33:37 -0700 Hi everyone! I would like to create a drop down list with the info in my database. I would also like to have more options so it will filter down to many rows of data displayed then filtered down to a few rows of data that said user is looking for. Kind of like select a state then in the next box you can select the city. but first thing is first..... I have tried a few things out there that I searched for but everything I tried it will not populate the drop down list with the data in my database. So I know it somewhere along the lines of: $query = mysql_query("SELECT root FROM training"); echo "<form action=something.php method=POST><select name=Field>"; while ($r = mysql_fetch_array($query)) { $user = $r["username"]; echo "<option value=$user>$user</option>"; } echo "</select>"; or something like that but nothing populates.... What is the proper code to get this done to populate and display what I select from the drop down menu? Say my DB name is: TUBA My table name is: FLUTE and I have xxx amounts of rows to filter through with three columns in my mysql db. Does that all make sense? Thanks in advance! You all rock!! sb -- AOL IM: Jestrix1 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php_________________________________________________________________ RealLiveMoms: Share your experience with Real Live Moms just like you http://www.reallivemoms.ca/