Sorry this is so basic, how to do an equal or greater than filter
2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 25, 2017 (RSS)
Hi all,
apologies if this is a real basic question.
I have a search form which displays apartments which can sleep the number of people chosen from the dropdown list (thanks cmsb cookbook) however I want the form to return apartments which are not just equal to but also greater than the number selected.
For example if there are 4 guests the list displays apartments which will accommodate 4 guests, I want it to display all apartments which can display equal to or greater than the number selected.
My existing code is below, 'sleeps' is the field containing the numeric number, how do I need to amend it to list equal or greater than the number selected and then sort it into ascending numerical order?
Thanks in advance for any help provided.
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<select name = "sleeps" >
<option value="">How Many Guests</option>
<?php foreach (getListOptions('apartments', 'sleeps') as $value => $label): ?>
<option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['sleeps']);?>>
<?php echo $label; ?></option>
<?php endforeach ?>
</select>
<input type="submit" name="submit" value="Search" >
</form>
By ross - January 25, 2017
Hi there.
Thanks for posting.
We might end up having to look at the code on your "results" page and make some changes there but for now, here's a change you can make.
<select name = "sleeps_min" >
Notice how I added the "_min" to your field name.
When the form submits to your results page, CMS Builder will automatically know to filter your results.
Give this a shot and let me know how you make out.
Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/