PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 31st, 2004, 07:51 AM
dotty dotty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 7 dotty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!

Reply With Quote
  #2  
Old June 1st, 2004, 06:21 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
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:
if (strlen($_post[drop1]) != 0) {$noError false;} 


then further down you write:

PHP Code:
if ($noError true) {-=Do search=-} else print "dropdown 1 value = '$_post[drop1]'"


-pheifel

Reply With Quote
  #3  
Old June 7th, 2004, 11:26 AM
dotty dotty is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 7 dotty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

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.


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Need help with search & filter problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT