NerdConcepts Posted March 11, 2007 Share Posted March 11, 2007 I'm been playing with this for a few days and I can't seem to come close to getting this to work. Here is the situation. End users use their zip code to search for businesses. Well I want the search to show more then just what is in their zip code but really in their area. Easiest way I have found to do this is displaying all businesses that start with the same 3 digitals as their zip code. Example: there are businesses in Joplin, MO (64801) and in Neosho, MO (64850). When someone types in 64801 (Joplin) I want it to show the businesses in Neosho (64850) also. So if someone could maybe help me out a little I would appreciate it. Link to comment https://forums.phpfreaks.com/topic/42239-solved-pulling-only-3-digits-from-a-query-result-issues/ Share on other sites More sharing options...
paul2463 Posted March 11, 2007 Share Posted March 11, 2007 $zip = substr("64850", 0, 3) ; $query = "SELECT * FROM businesses WHERE zipcode LIKE '$zip%'"; Link to comment https://forums.phpfreaks.com/topic/42239-solved-pulling-only-3-digits-from-a-query-result-issues/#findComment-204905 Share on other sites More sharing options...
chrisuk Posted March 11, 2007 Share Posted March 11, 2007 you wouldnt want to have a static value for substr however...so what you should do is slightly amend Paul's suggestion to: $shortzip = substr($zip, 0, 3) ; Link to comment https://forums.phpfreaks.com/topic/42239-solved-pulling-only-3-digits-from-a-query-result-issues/#findComment-204908 Share on other sites More sharing options...
gerkintrigg Posted March 11, 2007 Share Posted March 11, 2007 Wicked! This is something I can use too... Thanks for that! Link to comment https://forums.phpfreaks.com/topic/42239-solved-pulling-only-3-digits-from-a-query-result-issues/#findComment-204912 Share on other sites More sharing options...
NerdConcepts Posted March 11, 2007 Author Share Posted March 11, 2007 Found my problem. When i was doing the query I wasn't using LIKE...ooops. Thanks a lot Link to comment https://forums.phpfreaks.com/topic/42239-solved-pulling-only-3-digits-from-a-query-result-issues/#findComment-205081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.