-1

I want to catch these lat,lng,and inf arrays inside javascript in html and then want to plot a map

while ($obj = $res->fetch_object())  // get all rows (markers)
{<br>
    $lat[$mrk_cnt] = $obj->lat;  // save the lattitude<br>
    $lng[$mrk_cnt] = $obj->lng;  // save the longitude<br>
    $inf[$mrk_cnt] = $obj->MAXTEMP;  // save the info-window<br>
    $mrk_cnt++;                      // increment the marker counter<br>
}
<br>
Ivan Barayev
  • 2,035
  • 5
  • 24
  • 30

2 Answers2

0

you can pass php array into java script into html file

<script>
  var lat= <?php echo json_encode($lat); ?>
 var lng= <?php echo json_encode($lng); ?>
 var inf= <?php echo json_encode($inf); ?>
</script> 
NLSaini
  • 257
  • 1
  • 10
-1

Make an ajax call from your html file to the php file and store the result in javascript array.

A link to Ajax turotial: http://labs.jonsuh.com/jquery-ajax-php-json/

Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78