wkilc Posted August 17, 2010 Share Posted August 17, 2010 Hi, I've can use the following URL to filter the query below: www.mysite.com?levels=PreK ...this will show me alll the PreK members. www.mysite.com?levels=Elem ...this will show me all the Elem members. How do I filter it to show both me BOTH the PreK and Elem members? Do I need to change the query? WHERE ((user_info.Type LIKE '$Type%') and ((user_info.snr_First LIKE '%$name%') or (user_info.snr_Last LIKE '%$name%')) and (user_info.snr_Home_phone LIKE '$snr_Home_phone%') and (user_info.snre_eMail LIKE '$snre_eMail%') and ((user_info.PreK LIKE '$levels%') or (user_info.Elem LIKE '$levels%') or (user_info.MS LIKE '$levels%') or (user_info.HS LIKE '$levels%') or (user_info.College LIKE '$levels%') or (user_info.Admin LIKE '$levels%') or (user_info.Prvt LIKE '$levels%'))) ORDER BY user_info.$sort LIMIT $eu, $limit "; $result = mysql_query($query); Thanks. ~Wayne Quote Link to comment Share on other sites More sharing options...
petroz Posted August 17, 2010 Share Posted August 17, 2010 You could just do two different queries and check to see if Levels is set. If(isset($levels)){ //query with levels } else { //query without levels } Quote Link to comment Share on other sites More sharing options...
wkilc Posted August 17, 2010 Author Share Posted August 17, 2010 Thank you. Not sure if I follow... how would the URL query look in that case? ~Wayne Quote Link to comment Share on other sites More sharing options...
ober Posted August 17, 2010 Share Posted August 17, 2010 That depends on what is in $levels. And you can't really get both of those without breaking the query for the rest of them. Quote Link to comment Share on other sites More sharing options...
wkilc Posted August 17, 2010 Author Share Posted August 17, 2010 Thank you. So there's no practical way to do it? ~Wayne Quote Link to comment Share on other sites More sharing options...
ober Posted August 17, 2010 Share Posted August 17, 2010 Not without knowing the rest of the code. I'm guessing there is a lot more going on than what you showed us there. Your best bet is to modify the code to query the DB for multiple groups and levels instead of just levels. Quote Link to comment Share on other sites More sharing options...
wkilc Posted August 17, 2010 Author Share Posted August 17, 2010 Something like this? (I say like this... because I've done something wrong ...and this gives me an error.) WHERE ((user_info.Type LIKE '$Type%') and ((user_info.snr_First LIKE '%$name%') or (user_info.snr_Last LIKE '%$name%')) and (user_info.snr_Home_phone LIKE '$snr_Home_phone%') and (user_info.snre_eMail LIKE '$snre_eMail%') and ((user_info.PreK LIKE '$levels%') or (user_info.Elem LIKE '$levels%') or (user_info.MS LIKE '$levels%') or (user_info.HS LIKE '$levels%') or (user_info.College LIKE '$levels%') or (user_info.Admin LIKE '$levels%') or (user_info.Prvt LIKE '$levels%')) and (user_info.PreK AND user_info.Elem LIKE '$primary%')) ORDER BY user_info.$sort LIMIT $eu, $limit "; $result = mysql_query($query); Thanks. ~Wayne Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.