This is caused by calling
mysql_query to get data while you're looping over the results from another call.
At the moment you are calling
getLocation for every result. So if you have 10 results you are making 10 calls to the database which will all return the same thing.
Instead, change the
getLocation call to return a string and call it before the loop:
$location = getLocation();
Then in the loop you can do:
<?php echo $location ?>