rurede05 Posted October 23, 2009 Share Posted October 23, 2009 I am sure there is a very simple answer to this question but I am not very good at coding php. Situation: I have an online form that queries a MySql db by the first three digits of zipcode. I have certain information that goes out depending on the range of the zipcode. Example: User types 45678 in the ZipCode space on our form. On submission, it then queries the db to find out what information needs to be emailed that pertains to the first three digits of that zipcode in this case 456. On the db there I have a range for the zipcodes. From 456-499 send X information... From 500-567 send Y information... etc. My Dilemma: The code reads as follows: "SELECT `information` FROM tableName WHERE '$ZipCode' >= ZipCodeStart AND '$ZipCode' <= ZipCodeFinish"; Big problem: When I test the last number in the range (499 or 567) in our example above. It spits out a generic e-mail instead of the detailed e-mail with the data that is stored in the database. Not a problem except that it should spit out the detail data since it is stored and programmed to do that. Any number that lands between the range (say 460 again with the example numbers above) everything works fine. It only spits out the generic email with the last numbers of the ranges. I am confused because the >= and the <= should handle those easily correct? Am I overthinking/looking something? Thanks for your help in advance. Quote Link to comment https://forums.phpfreaks.com/topic/178787-greater-than-or-equal-to-and-less-than-or-equal-to-not-working/ Share on other sites More sharing options...
.josh Posted October 23, 2009 Share Posted October 23, 2009 thinking maybe you need to group your two conditions. (...) and (...) but also an alternative would be to use between Quote Link to comment https://forums.phpfreaks.com/topic/178787-greater-than-or-equal-to-and-less-than-or-equal-to-not-working/#findComment-943139 Share on other sites More sharing options...
rurede05 Posted October 23, 2009 Author Share Posted October 23, 2009 I tried the (...) nothing....I had BETWEEN before but if I had something like Range 500-500 it didn't send the information for that range... Thanks for trying though I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/178787-greater-than-or-equal-to-and-less-than-or-equal-to-not-working/#findComment-943153 Share on other sites More sharing options...
fenway Posted October 31, 2009 Share Posted October 31, 2009 "Sending" is not a mysql problem -- confirm that you're getting back the rows you expect. Quote Link to comment https://forums.phpfreaks.com/topic/178787-greater-than-or-equal-to-and-less-than-or-equal-to-not-working/#findComment-948392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.