Re: [PHP-DB] Creating drop down lists
Your select is only selecting the field 'root' but then you're trying to get the field 'username' in your while loop. So, you can add username to your select (or change it to *): select root, username from training select * from training Regards, Bruce >>> Scott <[EMAIL PROTECTED]> 11/03/2007 12:33:37 a.m. >>> 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 ""; while ($r = mysql_fetch_array($query)) { $user = $r["username"]; echo "$user"; } echo ""; 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Creating drop down lists
close $query = mysql_query("SELECT root FROM training"); echo ""; if($mysql_num_rows($result)>0){ while ($r = mysql_fetch_array($query)) { $user = $r["username"]; echo "$user"; } } echo ""; 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 <[EMAIL PROTECTED]> 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 ""; while ($r = mysql_fetch_array($query)) { $user = $r["username"]; echo "$user"; } echo ""; 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/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php