|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How do I setup query for either keyword or drop down search?
I have a database that I want to be able to search by either keyword or a drop down list. The way it is currently set up on my site, the dropdown category menu searches the category field of my database with one php script, and the keyword search uses a different php script to search the ingredients field of the database.
Can I... 1. Make 1 php script with the (Select FROM etc etc) setup to handle both a keyword and select input, but not at the same time? or, 2. Use 2 <form action> tags, one for the keyword and one for the drop down select, in one HTML document and still use the 2 separate php scripts? Any help is appreciated |
|
#2
|
||||
|
||||
|
RE: How do I setup query for either keyword or drop down search?
1. One PHP script:
2. Two forms in one HTML file Code:
<form action="search_script.php" method="get"> <input type="text" name="keyword"> <input type="submit" value="Search by keyword"> </form> <br> <form action="search_script.php" method="get"> <select name="category"> <option value="cat1">Category 1</option> <option value="cat2">Category 2</option> <option value="cat3">Category 3</option> </select> <input type="submit" value="Search by category"> </form> |
|
#3
|
|||
|
|||
|
RE: How do I setup query for either keyword or drop down search?
I tried this setup, and it only partly worked.
1. Do both of the form action tags need to point to the same php script to do the search? I tried them going to separate scripts, and the same script, and only one would work properly at a time. 2. If they both point to the same search script, and I add the php code listed above, then how would I set up the SELECT FROM part of the search script? Each form action searches a different field, so can the SELECT FROM statement query by 2 potentially different search variable passed to it? |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > How do I setup query for either keyword or drop down search? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|