On my site, users can search a database for other users. The search results display information about each individual user. Currently, to get the information I need, I use several SELECT statements to query different tables. But I have a feeling that there is a simpler way to do it.
The name of each table that I am using is as follows:
Here is the code and select statements:
//Find members with this zipcodeid and calculate distance
$sql = "SELECT zipcode.zipcodeid, 3963 * ACOS(COS(RADIANS(90-40.615000)) * COS(RADIANS(90-zipcode.latitude)) + SIN(RADIANS(90-40.615000)) * SIN(RADIANS(90-zipcode.latitude)) * COS(RADIANS(-111.891300-zipcode.longitude))) AS dist, members.*, photos.* FROM members LEFT JOIN zipcode ON members.zipcodeid = zipcode.zipcodeid WHERE members.zipcodeid LIKE '28063' ORDER BY dist";
$result = mysql_query($sql) or die(mysql_error());