dmccabe Posted September 26, 2008 Share Posted September 26, 2008 Ok so I have a simple table and form. The form allows the person to input 2 numbers (start and end), then select a site name that these numbers apply to. eg: START = 1000 / END = 2000 / SITE = LONDON This then inputs the start number and end number along with the site id in to the table. I now need to add a search box so the user can enter a number and it will bring up the corresponding site name. However they need to search any number between the start and end no. So using the example about if the user search 1500 it should bring up the result as LONDON. I cant wrap my head around how I would do this? Link to comment https://forums.phpfreaks.com/topic/125928-solved-is-this-possible/ Share on other sites More sharing options...
thebadbad Posted September 26, 2008 Share Posted September 26, 2008 <?php $n = 1500; switch (true) { case ($n >= 1000 && $n <= 2000): echo 'London'; break; //etc. default: echo 'Site not found'; } ?> Just make sure the ranges aren't conflicting. Link to comment https://forums.phpfreaks.com/topic/125928-solved-is-this-possible/#findComment-651170 Share on other sites More sharing options...
dmccabe Posted September 29, 2008 Author Share Posted September 29, 2008 thanks thebadbad, I managed to work it out about 3 seconds after posting this question. Thanks anyway though Link to comment https://forums.phpfreaks.com/topic/125928-solved-is-this-possible/#findComment-652890 Share on other sites More sharing options...
redarrow Posted September 29, 2008 Share Posted September 29, 2008 use a if statement not a switch be quicker.............. Link to comment https://forums.phpfreaks.com/topic/125928-solved-is-this-possible/#findComment-652893 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.