i have bit strange problem. I am fetching latitude and longitude of place in my php. demo latitude and longitude are like this
Latitude 20º 24.002' N
Longitude 87º 18.135' W
The problem is because of º
the data is not retrieved. how to get latitude with º
?
Here is my query
$sql = "select * from tbl_site where sit_id =".$_GET[id];
After fetching data I have this array:-
{"item":{"sit_id":"3","sit_title":"title","sit_image":"img2.jpg","sit_zon_id":"1","sit_access":"Boat","sit_rating":"5","sit_experience":"all divers","sit_latitude":null,"sit_longitude":null}}
Code that fetches from database and parses to JSON:
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare($sql);
$stmt->bindParam("id", $_GET[id]);
$stmt->execute();
$employee = $stmt->fetchObject(); $dbh = null;
echo '{"item":'. json_encode($employee) .'}';
First utf8_encode your php code than try to decode with java-script or string replace
You may use GEOMETRY spatial extention in this case to store lat,long.
to store a point on map, you can use POINT(long,lat)
.
And, convert your latitude, longitude from degree to decimal.
So, your each point should look like:
POINT(20.xxxx, 87.xxxx);