View Full Version : Populating results query based on Selection in a drop down box

07-29-2008, 04:23 PM
Hi guys

I have a drop down box, which is populated by a table called portfolio_cat.

It has 3 id's in it, 1, 2 and 3.

This portfolio_cat table is linked up to a table called portfolio which has info on details of a specific job. Ie Location, Jobtitle, ID, Images and cat_id (this one is linked to the portfolio_cat table.)

Basically when a user clicks on the drop down and selects ID 2 for example.
I want it to pull out all the information in the portfolio table that has a cat_id of 2 and display it on the page.

How the hell do I do that????

Any help would be great


07-29-2008, 04:28 PM
if you want it to respond to an action on the user end you need a client side scripting language ie js

i think what you really want is ajax. you can rig it to drop whatever info you want into the page on the fly based on the user's choice.

07-29-2008, 04:39 PM

As i don't have any experience with Javascript or Ajax, would it be easier if I had three links instead of a drop down????

Then when they click on a link it will transfer them to a page where it will display all records with a value of 1, or a page displaying all records with a value of 2 etc???

Or does anybody have the code I need to do it through a drop down

Any help, advice or code would be appreciated.


07-29-2008, 05:27 PM
you know what, i didn't read that closely enough the first time.

if you're fine with a dropdown and a submit button, and you're fine with the page refresh then you don't need js or ajax etc

display the dropdown etc, html code and form goes here, post to self
$id = strip_tags($_POST['dropdownvalue']);
$query = 'SELECT `stuff` FROM `somewhere` WHERE `ID` = "'.mysql_real_escape_string($id).'"';

run the $query, display the results as normal