I have one resultset, How can i pass its value to a javascript function ,and move internal pointer to next row.
<?php 
$q=mysql_query("select * from tbl_map")or die(mysql_error());
$i=0;
?>
<script>
$(document).ready(function() {
// Initialize the Google Maps API v3
var map = new google.maps.Map(document.getElementById('map'), {
  zoom: 15,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = null;
function autoUpdate() {
<?php 
mysql_data_seek($q,$i);
$row=mysql_fetch_assoc($q);
$i++;
?>
lat=<?php echo $row['latitude']; ?>;
long=<?php echo $row['longitude']; ?>;
  navigator.geolocation.getCurrentPosition(function(position) {  
    var newPoint = new google.maps.LatLng(lat, 
                                          long);
    if (marker) {
      // Marker already created - Move it
      marker.setPosition(newPoint);
    }
    else {
      // Marker does not exist - Create it
      marker = new google.maps.Marker({
        position: newPoint,
        map: map
      });
    }
    // Center the map on the new position
    map.setCenter(newPoint);
  }); 
  // Call the autoUpdate() function every 5 seconds
  setTimeout(autoUpdate, 5000);
}
autoUpdate();
      });
</script> 
I want to fetch latitude and longitude from database and pass to autoupdate() but i can not move internal pointer ahead. How to fix ?
 
    