I have a table which searches the theaters from database based on zip code, currently i have used this query to sort results, but i want the exact matched location first and then nearby location in while loop Is there any way, i have searched but all are showing that we need latitude and longitude to perform this search , but for now i haven't stored such info in database. Please advice.
if($_GET['zip'])
{
$zip_get= trim($_GET['zip']);
$zip_three=substr($zip_get, 0, 3);
$theatre_query= mysql_query("select * from (Select *,(CASE WHEN zip = '$zip_get' THEN 2 ELSE 0 END + CASE WHEN zip < $zip_get THEN 1 ELSE 0 END ) as nummatches from theatre ) where nummatches>0 and campaign='$camp' and zip LIKE '".$zip_three."%' order by nummatches desc, zip desc");
}