I want to display all of my markers stored in the database. I want to use ajax to retrieve all the markers` latitude and longitude in my database and use it to display the markers in the map.How to loop in ajax?
$.ajax({
url: 'php_action/map/fetchmarker.php',
dataType: 'json',
success:function(response)
{
var plate = response[1];
map.addMarker({
lat: response[2],
lng: response[3],
title: plate
});
}
});
fetchmarker.php
<?php
$sql = "SELECT t_id,b.b_platenum,t_lat,t_long from tbltrackbus as a inner join tblbusdesc as b on a.t_bid=b.b_id";
$result = $connect->query($sql);
if($result->num_rows > 0) {
$row = $result->fetch_array();
} // if num_rows
echo json_encode($row);
?>