AndrewJ1313 Posted January 22, 2009 Share Posted January 22, 2009 I would like to at a ZIP/ Postal Code look-up to a site. There are basically 22 zones covering the U.S and Canada and I would like to direct users to certain information depending on what ZIP code they enter. In most cases, entire states are in one zone. My question is, is there a way to write an IF statement that would cover a number range? An example would be I want all ZIP codes ranging from 40000 through 49999 to be directed to zone 1. Can I write this without saying: IF $zip = "40000" || $zip = "40001 || $zip = "40002" ... Please let me know if this makes sense or if I need to clarify what I'm doing. Thanks for all responses, Andrew Link to comment https://forums.phpfreaks.com/topic/141938-solved-zip-postal-code-look-up-feature/ Share on other sites More sharing options...
phparray Posted January 22, 2009 Share Posted January 22, 2009 if($zip >= 40000 && $zip <= 49999) Link to comment https://forums.phpfreaks.com/topic/141938-solved-zip-postal-code-look-up-feature/#findComment-743187 Share on other sites More sharing options...
AndrewJ1313 Posted January 22, 2009 Author Share Posted January 22, 2009 if($zip >= 40000 && $zip <= 49999) You know, the minute I posted this, I started to think I was over thinking the whole thing:) Thanks this will help. And just in case anyone knows a better way to build a ZIP code look-up feature, I'm all ears...or eyes in the case of blogging. Many thanks for the help. Andrew Link to comment https://forums.phpfreaks.com/topic/141938-solved-zip-postal-code-look-up-feature/#findComment-743193 Share on other sites More sharing options...
printf Posted January 22, 2009 Share Posted January 22, 2009 Zip Code ranges are not actually zone specific. Why not just add a zone field to your database and do the redirection and show the specific zone data based on the exact zip code. Link to comment https://forums.phpfreaks.com/topic/141938-solved-zip-postal-code-look-up-feature/#findComment-743195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.