I am trying to return records based on the cities that someone chooses. It works fine with one city. But I tried to put the “OR” in there and it still only returns results for one city. Not both. Am I doing something wrong here. It looks okay to me but I have to be doing something wrong.
$result = mysql_query("
SELECT
lat,lng,id,re,per_num,name,city,state,zip,address,status,category,size,
( 3959 * acos( cos( radians(40.000000) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(-75.000000) )
+ sin( radians(40.000000) )
* sin( radians( lat ) )
)
) AS distance
FROM
buildings
WHERE
(city='$cities[0]' OR city='$cities[1]')
AND re='$re2'
AND status='$status2'
AND size='$size2'
HAVING
distance < 25
ORDER BY
distance
LIMIT
0 , 20
");
Your request is constrained not only by your $cities entries but also by
And also by
May the missing city entrie not comply to any of those constraints, it won’t be in the request result.