I will try to explain it in detail. I am not trying to insult your intelligence, I just don\'t want to leave anything out. Hope this makes sense. Thanks for your help.
I am trying to build a store locator database. I have a table that holds the storename, address, city, state, zipcode, relatedzip, relatedzip2, and relatedzip3.
When someone types in the zipcode they live in, it first trys to find a match in the zipcode field. If it finds a match it displays the pertinent information for that store.
I have relatedzip, relatedzip2, and relatedzip3, because even though a store may not be in the zipcode that the person typed in, they could actually be closer to a store that wasn\'t in there zipcode, than to one that was actually in there zipcode. The zipcodes I have in the relatedzip, relatedzip2, and relatedzip3 all relate to an actual store. So for instance, say someone typed in zipcode 55555. First I selected all from the table where that 55555 matched up with the zipcode field. If there was a match, I displayed the pertinent store data. Then I want to check and see if relatedzip, relatedzip2, and relatedzip3 have zipcodes in them. So for instance, say that row that matched up with 55555, had 66666 in the relatedzip field. I wrote this select statement: $sql = \"SELECT * FROM tbl_stores WHERE $relatedzip = zipcode\"; to check for that. It takes 66666 and searches for a match in the zipcode field, and then displays the data for that store.
So what I want to happen is, if relatedzip, relatedzip2, and relatedzip3 all have zipcodes in them, I want to display those results as well. What is happening is, it takes the zipcode they entered, finds a match in the zipcode field, and displays the data. Then it sees if there is anything in relatedzip, if there is, it displays it. Then it looks in relatedzip2, and if there is something in there it is supposed to display it. Well it doesn\'t, unless I comment out the code for relatedzip, then it will display the data for relatedzip2.
Once again, sorry for the length of my reply. I really appreciate your help.
JDawg