Filtering MySql Query for Distance Calculation

Hibrida GSM

New Member
I'm looking for some help with a query which I'm pretty sure is straightforward but I can't see the wood for the trees, I hope someone can help.I'm searching my database of users, calculating the distance between users and outputting results as follows:\[code\]$result = queryMysql("SELECT user FROM $table WHERE x= 'y'");$num = mysql_num_rows($result);for ($j = 0 ; $j < $num ; ++$j) { $row = mysql_fetch_row($result); if ($row[0] == $user) continue; $query = "SELECT * FROM $table WHERE user='$row[0]'"; $res=mysql_query($query); $results=mysql_fetch_assoc($res); $userlocation=$results['location']; //run distance function which outputs $distance if($distance <= $maximumdistance) { //echo user info }\[/code\]What I want to do is run the distance function, identify the users who it returns as true, and get their user ids (unique), either in an array or something else, so i can count the results and then run through them for output.Does this make sense and/or is there a better way of doing this.Thanks
 
Back
Top