I am returning results from Wordpress custom table. The results are an array of coordinates. I want to set map markers with each set of coordinates from the array. I need to do this dynamically, i.e.- (while there are coordinates, set a marker). However, when I try using a while loop, I get infinite loop.

each of these contains multiple values(coordinate sets):
PHP Code:
$latlong['lat'], $latlong['long'
How could I loop through each, get to the last row of table, then stop. One criteria is that the number of results will vary depending on user query.

I know that javascript for loop is used for specific number of results, but not sure how I would use that to implement this.

Ultimately, I want each result to use with this:

PHP Code:
var places = [];

    places.push(new google.maps.LatLng( <?php echo $latlong['lat'?><?php echo $latlong['long'?> ) );



    for (var i = 0; i < places.length; i++) {

        var marker = new google.maps.Marker({
            position: places[i],
            map: map

    });