Dropdown Select

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Dropdown Select

Post by jayson.ph »

Hi all,

Can i request for help, i have a drop-down ff. => http://i48.tinypic.com/35a3vqa.jpg and my preoblem now is SELECTING FROM LIST. i know you are all familiar from this. i just like, when i was select category: netbook-> the next paroduct name: all netbook product will be available to select. :

I have code for selecting category, but the next product name, i reallt have no idea, what to do.

Code: Select all

$query = "SELECT cat_name FROM tbl_category";
			$x = mysql_query($query);
			echo "Category: <select name = 'slc_inbranch'>";
				while($v = mysql_fetch_array($x))
			{
			echo "<option value = $v[cat_name]> $v[cat_name]</option>";
			}
			echo "</select>";


Please help, very needed..
Last edited by jayson.ph on Thu Jun 14, 2012 8:26 pm, edited 1 time in total.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Dropdown

Post by Celauran »

I'm guessing you want each dropdown to refine the choices available in the next? If so, you'll want an AJAX solution. How are you currently approaching the problem? Where are you running into problems? Can you post some code?
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Dropdown Select

Post by jayson.ph »

ah yes, and i use your code to validate username and passwrd.. thank a lot, can you help me.. regarding the dropdwn. and after this project, i show you all.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Dropdown Select

Post by jayson.ph »

i forgot the Category table. here: http://i50.tinypic.com/fmm7br.jpg
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Dropdown Select

Post by Celauran »

Essentially what you want is to have a jQuery listener on each of those select boxes. When the selected item changes, use $.post() to query the database asynchronously.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Dropdown Select

Post by jayson.ph »

Ah no, simply i need the list product base in category selected.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Dropdown Select

Post by jayson.ph »

Please help, a little idea regarding drop-down.
example: when i select category like-> laptop the next selection on product name: all kinds of laptop will be appear on the product name.

Please i really need help..
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Dropdown Select

Post by Celauran »

jayson.ph wrote:when i select category like-> laptop the next selection on product name: all kinds of laptop will be appear on the product name.
That's what I was talking about initially and you said no.

Do you have any familiarity with AJAX? jQuery?
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Dropdown Select

Post by jayson.ph »

ah okay, sorry... but do you have a sample to show me, and i try to learn it. please
Post Reply