bbb Posted October 25, 2018 Share Posted October 25, 2018 I think I'm going to get an obvious duh answer here. I have a "number of guests" text field. It's a text field because most of the time the value of this field is an int value but in some cases it's "100 guests" or "120-200" I have the following code where $g_guests is just a GET variable. $query = 'template="party", '; if(isset($g_guests)){ foreach($g_guests as $g_guest){ switch ($g_guest) { case 50: $query .= 'guests=(party_guests>=1, party_guests<51), '; break; case 100: $query .= 'guests=(party_guests>=51, party_guests<101), '; break; case 150: $query .= 'guests=(party_guests>=101, party_guests<151), '; break; case 200: $query .= 'guests=(party_guests>=151, party_guests<201), '; break; case 201: $query .= 'guests=(party_guests>=201),'; break; } } } $parties = $pages->find($query); When I query between 1 and 51, I get pages back with all kinds of values een above 51. When I query more than 201, the results I get back changes and I see a few parties with 500 guests, but also 90, 80, etc My guess is I'm comparing apples and oranges as in, strings with ints. Is there some way to fix this without having to create a new int fields? Link to comment Share on other sites More sharing options...
elabx Posted October 25, 2018 Share Posted October 25, 2018 Apparently from what I find in the searches, it's just not going to work with text fields: 1 Link to comment Share on other sites More sharing options...
Robin S Posted October 26, 2018 Share Posted October 26, 2018 What @elabx said. And... 5 hours ago, Barry said: $query .= 'guests=(party_guests>=1, party_guests<51), '; ...is that intended to be a sub-selector? If so you need to use square brackets. $query .= 'guests=[party_guests>=1, party_guests<51], '; 1 Link to comment Share on other sites More sharing options...
bbb Posted October 27, 2018 Author Share Posted October 27, 2018 Its an optional OR selector. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now