gottberg Posted May 21, 2019 Share Posted May 21, 2019 (edited) Hi, The template has 2 fields with numbers, lets call them n1 and n2. I want to find the page which fits my current number. For example my number = 10 Pages: PageID 1: n1 1 - n2 10PageID 2: n1 11 - n2 20PageID 3: n1 21 - n2 30 So i want this to return the pageID 1. With mySQL it would be something like this: SELECT * FROM numberTable WHERE 1265 BETWEEN `FROM` AND `TO`; I have tried multiple selectors but can't get it to work. Any suggestions? Edited May 21, 2019 by gottberg SOLVED Link to comment Share on other sites More sharing options...
louisstephens Posted May 21, 2019 Share Posted May 21, 2019 I believe it is as simple as doing: <?php $p = $pages->get('template=your-template, n1|n2=10'); echo $p->id; ?> Link to comment Share on other sites More sharing options...
gottberg Posted May 21, 2019 Author Share Posted May 21, 2019 4 minutes ago, louisstephens said: I believe it is as simple as doing: <?php $p = $pages->get('template=your-template, n1|n2=10'); echo $p->id; ?> Thanks for the fast reply! I still get zero results, so i seems like its not working. ? Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 21, 2019 Share Posted May 21, 2019 It's probabably more like: $pages->get("template=your-template, n1<=$myNumber, n2>=$myNumber") Link to comment Share on other sites More sharing options...
gottberg Posted May 21, 2019 Author Share Posted May 21, 2019 7 minutes ago, LostKobrakai said: It's probabably more like: $pages->get("template=your-template, n1<=$myNumber, n2>=$myNumber") Thanks, this got it working! I tried this earlier but i must have had a spelling error. ? Link to comment Share on other sites More sharing options...
gottberg Posted May 23, 2019 Author Share Posted May 23, 2019 On 5/21/2019 at 7:23 PM, LostKobrakai said: It's probabably more like: $pages->get("template=your-template, n1<=$myNumber, n2>=$myNumber") Hi, This works great for numbers above hundred but it does not work when the range is 61-99 for example. Do you know what could cause the problem? EDIT: I solved the issue by using findOne(), wierd but now i get the results i wanted. 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