drop down menus

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sangeetha
Forum Newbie
Posts: 8
Joined: Sat Mar 11, 2006 12:00 am

drop down menus

Post by sangeetha »

Hi
i am new to PHP. I am using MySQl database. In my database i have a list of products which i want to dispaly in a form as a drop-down menu.
The problem is I dont know how to link my table frield to drop down menu.
Later i want to pass the selection from drop-down menu to PHP action script. How can i do that?

pls help me.

thanks in advance
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

#1 query your sql statement
#2 build your form element
#3 loop through your query results

like this

Code: Select all

$result = mysql_query("SELECT `foo` FROM `bar`");

echo "<select>";
while($array = mysql_fetch_array($result)){
   echo "<option value=\"{$array['foo']}\">{$array['foo']}</option>\n";
}
echo "</select>";
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

ha,thanks,this helped me also. :wink:
Post Reply