I'm trying to figure out why my query isn't working, but it doesn't make sense to me. I'm accessing a database via php that lists states and their affiliated cities/towns, and I have a javascript script which displays them as menus. Each state has an ID which is incremented by 100,000 (meaning in the database, "Alabama" is 100,000 and "Alaska" is 200,000.) So I tested my query out in MySQL and it works properly, and I tested the javascript value that was being sent to the php script and it was the correct one, but the returned menu is containing many more values than it should.
My query looks like:
mysql_query("SELECT * FROM fullstates WHERE code > '$state' AND code < '$state' + 100000");
where state is the ID of the previous state that was picked. The only thing I could think of is that the AND isn't working properly?
codeis a multiple of100000, then bothcode > $stateandcode < $state + 100000will fail!