Welcome to WebmasterWorld Guest from 54.167.5.15

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Pulling info from MySQL

Placing in a dropdown box - Any Help?

     

joe1182

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

10+ Year Member



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?

Paul in South Africa

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

10+ Year Member



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";
}

joe1182

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

10+ Year Member



Thanks Paul! Will this work to pull all of the customers in the customer field?

Paul in South Africa

1:01 pm on Dec 10, 2004 (gmt 0)

10+ Year Member



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.

joe1182

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

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month