|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help with search & filter problem
Hi,
I have a search page which needs to search 5 fields so I've made 5 drop down menus. If I use "OR" - user can only select one - using "AND" only works if a selection is made from all the menus. How do I handle the search so that if one or more of the selections are not made that it will still bring back results for the other parameters? And that if a selection is not made then the default will be that all the records in that field are searched? I'm sure this is not difficult as I see it all the time on websites - but I just can't get my head around how best to handle this. I also have another problem - in the SQL statement to make a recordset that shows results (SELECT id, name, company, etc. ) returns a pre-defined set of fields or (SELECT *) returns all fields - how can I get the results from a Multi-selection menu so that the user can bring up only the results they need? Something like (SELECT name_of_menu WHERE ...etc) - so is there some particular way that this should be defined? Thank you in advance to anyone who can help me with this! ![]() |
|
#2
|
|||
|
|||
|
Hi. The way you could do it, would be to use $_post['value']; this is written in the top of the line, and the searchfield is a post-form. then e.i: dropdown 1 = "hello", dropdown 2 = "bye" dropdown 3 = ""... etc. then you tjek id the collected postdata is emty ore not like this:
PHP Code:
then further down you write: PHP Code:
-pheifel |
|
#3
|
|||
|
|||
|
Thanks for your help Pheifel.
I managed to do it by using 'like' instead of '=' in the sql statement and putting '%' as the first value for each dropdown menu. This works really well. ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Need help with search & filter problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|