Added the array "$locationsArray" 

added...at the bottom of the page before the while loop 

$locationsArray = array("id", "locationId", "latitude","longitude",);  //creating an array for location information from select statement