Jump to content

Search in php


wernervantonder

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
Link to comment
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
Link to comment
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.
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.