Changed getlocationsfunc.php to use MySQL Query

Changed the getlocationsfunc to use a MySQL query instead of php loop.
Also changed some loops to better cover a range of eventualities. Lastly
changed INSERT INTO statements to use double quotes as there were issues
inserting descriptions or names of hotspots which included single quotes
(We may have the same issue if someone attempts to use double quotes)