I have one table with offices that cover a range of postcodes with zipcode lowest and zipcode highest. Another table with zipcodes linked to a city name,
The user searches for a city, and the database returns a array with each postcode linked to that city. Then i want my code to use this array of postcodes to search in the offices table and see if any of the values fits between max and min value.
lets say we searched for a town that returned these zipcodes
$search_string = 25002,25003,25004,25005,25006,25007,25008,25009,25013,25014, 25015,25018,25019,25022,25023,25024,25025,25053,25054,25100,25101,25106,25107,25108,25109,25110,25111,25112,25113,25114,25181,25183,25184
This was my attempt on a solution, thought it worked but apparently only workout for the first value.
$query = $this->db->prepare("SELECT contacts.id FROM contacts INNER JOIN contacts_postcodes_links ON contacts_postcodes_links.contact = contacts.id WHERE contacts.id != 0 ".$category1." ".$category2." AND :search_string BETWEEN contacts_postcodes_links.minValue AND contacts_postcodes_links.maxValue ORDER BY id DESC ".$limit."");
So the part that i need help with, is it possible to do something like this? If not, how would i solve this problem?
my_array BETWEEN contacts_postcodes_links.minValue AND contacts_postcodes_links.maxValue
postcode
store in database ? if isint
you can find min and max value in your search string and useBETWEEN