Database Forum
Web Database Register Members List Calendar FAQ

 
Go Back   Database Forum > Database Management > PHP & MySQL
User Name
Password

Reply
 
Thread Tools Search this Thread Display Modes
Default Creating a 2nd drop down list...
02-25-2008, 01:30 PM #1  

pickles
Junior Member

 
Status: Offline
Posts: 1
Join Date: Feb 2008

Hello. Another php question from a beginner.

I have a Drop down list that is being populated from a MySQL database. I want to be able to create a 2nd drop down list for certain items in the first drop down list. My first drop down list, lists categories of businesses. If a user selects "Restaurants" I want a second drop down list to appear where the user can choose a cusine if they want. I don't want it to be necessary to select an option from the second list but I want them to be able to. I dod have the first drop down list working. The code follows. I am not sure how to get started on the 2nd list. Any hints, points in the right direction, etc will be appreciated. Thanks!

<?php
$user = "***";
$host = "***";
$password = "***";
$database = "***";

$cxn = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
mysql_select_db($database,$cxn);

$query = "SELECT DISTINCT Category FROM clients ORDER BY Category";
$result = mysql_query($query,$cxn)
or die ("Couldn't execute query.". mysql_error());
/* create form containing selection list */

echo "<form action='processform.php' method='POST'>
<select name='Category'>\n";

while ($row = mysql_fetch_assoc($result))
{
extract($row) ;
echo "<option value='$Category'>$Category\n";
}
echo "</select>\n";
echo "<input type='submit' value='Select Category'>
</form>\n"
?>
Reply With Quote

Default
02-29-2008, 03:59 PM #2  

twenty1
Senior Member

 
Status: Offline
Posts: 221
Join Date: Mar 2005
Location: Iowa, USA

Maybe this thread will help.
Reply With Quote

Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 12:11 AM.

Powered by: vBulletin Version 3.7.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Database Forums

Help support our forum assistants and product development ->

go to top go to top