/    Sign up×
Community /Pin to ProfileBookmark

cascading dropdown list based on database

i need an assistant with cascading drop down list based on a database. the cascading dropdown must be 4 below its a from and database , please note i am new on php and sql

Here is my inputs
<div class=”control-group”>
<label class=”control-label”><?php echo get_phrase(‘country’);?></label>
<div class=”controls”>
<select name=”province” class=”uniform” style=”width:100%;”>
<option value=””><?php echo get_phrase(‘select_country’);?></option>
</select>
</div>
</div>
<div class=”control-group”>
<label class=”control-label”><?php echo get_phrase(‘province’);?></label>
<div class=”controls”>
<select name=”province” class=”uniform” style=”width:100%;”>
<option value=””><?php echo get_phrase(‘select_province’);?></option>
</select>
</div>
</div>
<div class=”control-group”>
<label class=”control-label”><?php echo get_phrase(‘region’);?></label>
<div class=”controls”>
<select name=”region” class=”uniform” style=”width:100%;”>
<option value=””><?php echo get_phrase(‘select_region’);?></option>
</select>
</div>
</div>
<div class=”control-group”>
<label class=”control-label”><?php echo get_phrase(‘branch’);?></label>
<div class=”controls”>
<select name=”region” class=”uniform” style=”width:100%;”>
<option value=””><?php echo get_phrase(‘select_branch’);?></option>
</select>
</div>
</div>

DROP TABLE IF EXISTS `member`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Member` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`country` char(35) NOT NULL DEFAULT ”,
`province` char(3) NOT NULL DEFAULT ”,
`region` char(20) NOT NULL DEFAULT ”,
`branch` int(11) NOT NULL DEFAULT ‘0’,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

Here are countries = Provinces

south_africa = Gauteng, Western Cape, Kwazulu nal
botswana = botswana
lesotho = Lesotho
mozabique = Other
namibia = Other
swaziland = Other
zimbabwe = Other
other

and here are my provinces

Province = Branch

Gauteng = Soweto, Johannesburg

Western Cape = Cape Town
Kwazulu natal = Durban
Botswan = Gaborone

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJun 26.2015 — What is this code doing for you? I don't see you building any dropdowns other than to define them with a default blank entry.

If you are trying to get us to help you write some php/html code why are you only now trying to create the database? Shouldn't you have that already built if you want help in actually using it?

Very confusing.

And what does this mean: "dropdown must be 4 below its a from and database"?

A rough approximation of the necessary code would be:

[/code]

// run some query that will get the desired data for your dropdown items

// Then start creating the html code for it

echo "<select name='dropdown1'>";

echo "<option value=''>Select a choice</option>";

// Now loop thru the query results and build the rest of the dropdown items

// (btw - I use pdo as my db interface)

while ($row = $pdo_handle->fetch($queryresults))

{

echo "<option value='{$row['dbvalue']}'>{$row['dbliteral']}</option>";

}

echo "</select>";

[/code]

Hope this explains it. May be a typo in there with the quotes in the option output. Untested.

Be sure you have php error checking turned on during your development phase!
×

Success!

Help @Maijane spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...