Jump to content

Archived

This topic is now archived and is closed to further replies.

wernervantonder

Search in php

Recommended Posts

I have two list boxes on a form on my webpage. I have a database that contains 9 fields including the two indexes : Area and Category.

Now what i want to do in sql is if i select a area in the first list box and then i select a category in the seccond list box i press a button Called find. I want to assign those current values to a variable and then use my select statement to filter those fields and display it.

How do i go about doing that. I do not want you guys to do my work for me i just want an idea as to the working on this. What wording do i use to assign the values of the list box to a variable.

Thank you so much

Werner

Share this post


Link to post
Share on other sites
its not entirely clear what you are trying to do but perhaps you are looking to create dynamic dropdowns from variables in your db then take the value of the selection in the dropdown when the user submits and pass that into the sql query... so you would need to do $filter=value(dropdown1) $filter2=value(dropdown2)
sql query= select blah from foo WHERE $filter = value and $filter2 = somethign else

Share this post


Link to post
Share on other sites
Not sure I fully understand. But what is sounds like is you have a form, with two list boxes, you make the submit button labeled Find, when they click find the page reloads and values of the listboxes are posted, either GET or POST and then you simply append those variables in your MYSQL WHERE clause. I could be way off though.

Share this post


Link to post
Share on other sites
What is value(dropdown1)? I could be wrong, but I am aware of a PHP method call named value().

Share this post


Link to post
Share on other sites
lol its me being stupid and writing it out as a function cause its 2am.... its not a function it should just be whatever value was selected from the dropdown menu.....

Share this post


Link to post
Share on other sites
Thanx guys it is greatley appreciated, You got the right idea i basicaly want to take the selections made in listboxes and click submit button and execute php where i assign those values to variables :$area and $category with sql that says select*from databse
WHERE $area = listbox1
and $category = listbox2.

so my question is wht wording do i use to assign those listboxes selected content to variable?

thanks werner

Share this post


Link to post
Share on other sites
Once you submit the form, the values of the boxes are sent to method, either GET or POST. So you can access them by:

$_GET['listbox_name'] or $_POST['listbox_name']

IF YOU HAVE REGISTER GLOBALS ON, THEN YOU CAN ACCESS BY SIMPLY:

$listboxname

Share this post


Link to post
Share on other sites
Thank you for your help it helped. how ever i have a new question please assist me if you can!
The subject is called : mysql_numrows():

I realy appreciate your help!

Werner

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.