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 Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/ 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 } Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/#findComment-1100442 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 Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/#findComment-1100477 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. Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/#findComment-1100479 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 Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/#findComment-1100482 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. Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/#findComment-1100484 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 Link to comment https://forums.phpfreaks.com/topic/210974-url-query-for-two-values/#findComment-1100491 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.