Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Pulling info from MySQL

Placing in a dropdown box - Any Help?

     
11:51 am on Dec 10, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Nov 19, 2004
posts:219
votes: 0


I need to add a drop down box to a HTML form but, I need the choices in the box to be pulled directly from a field in MySQL. Any ideas on how to do this?
12:07 pm on Dec 10, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 9, 2003
posts:180
votes: 0


This should point you in the right direction

$result = mysql_query("SELECT * FROM $table");
while ($a_row = mysql_fetch_row($result))
{
print "<option value=\"$a_row[0]\"";
if ($id == $a_row[0])
print "selected";
print ">$a_row[1]</option>\n";
}

12:41 pm on Dec 10, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Nov 19, 2004
posts:219
votes: 0


Thanks Paul! Will this work to pull all of the customers in the customer field?
1:01 pm on Dec 10, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 9, 2003
posts:180
votes: 0


You will have to adjust the query to get the information you require out of the database table.

$result = mysql_query("SELECT * FROM $table"); will select all records from a table. To help you in your specific situation we need to know what fields your table has and what information you need to extract.

2:05 pm on Dec 10, 2004 (gmt 0)

Full Member

10+ Year Member

joined:Nov 19, 2004
posts:219
votes: 0


The table is "customers" the fields are as follows. 'client name', 'bill to address', 'shipping address', 'phone', 'contact name'.

I want the 'client name' choices to display in the drop down box and once the client name is selected all of their information will be pulled from the table. I guess my problem is getting all of the client names in the database to display in the dropdown box as an option to select.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members