$selection = "some columns to select"; $zipcode = "11787"; //this can be any zip code, it's not really hardcoded like this. $low = $zipcode - 2500; //the lowest number we'll consider a close enough match $high = $zipcode + 2500; //the highest number we'll consider a close enough match //the ABS stuff below is just to order the results by the closest to $zipcode $query = "SELECT $selection, ABS(zipcode-$zipcode) AS distance FROM ourDB WHERE zipcode BETWEEN $low AND $high ORDER BY distance";
so we have $zipcode which is a php variable, and zipcode which is a column in our DB. right now the column only has one zip, but I'd like to have multiple zips and still do the whole search in mysql. the alternative is to have a comma separated list, grab ALL the zipcodes into php, explode, and loop through with php.. what a pain..
any ideas? thanks everyone