I am having a hard tme doing this and I tried many attempts but it still won't work. I need to put the name, latitude and longitude in the var = locations[];
The purpose of this code is to show the locations of the places in a 2D Map
<div id="map" style="width: 1150px; height: 500px;"></div>
<?php  
require 'dp.php';
$db = new DB();
$records = $db->shop_locat();
if(isset($records)) {
    foreach($records as $row) {
        echo '<script type="text/javascript"> var locations = [ ';
        echo ' [ '.$row['name'].' , '.$row['lat'].', '.$row['lng'].' ]; </script> ';
    }
}
?>
<script type="text/javascript">
// The original code... var locations = [['Vista Mall Bataan', 14.655008481768526, 120.5338206800952],];
var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 10.5,
    center: new google.maps.LatLng(14.6417, 120.4818),
    mapTypeId: google.maps.MapTypeId.ROADMAP
});
        
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {  
    marker = new google.maps.Marker({
        position: new google.maps.LatLng( locations[i][1], locations[i][2] ),
        map: map});
          
    google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker);
        }
    })(marker, i));
}
</script>
dp.php
// Get Coordinates
    public function shop_locat() {
        $qstr = "SELECT * FROM tbl_location";
        $result = mysqli_query($this->link, $qstr);
        $records = array();
        if (mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_assoc($result)) {
                $records[] = [
                    'lat' => $row['lat'],
                    'lng' => $row['lng'],
                    'name' => $row['name'],
                    
                    
                ];
            }
        } else {
            $records = null;
        }
        mysqli_free_result($result);
        return $records;
    }
I tried multiple variations of but it still won't work. So I am hoping that someone can help me.
This is the output that I want, but the name, latitude, and longitude is like this:
var locations = [['Vista Mall Bataan', 14.655008481768526, 120.5338206800952],];

The name, latitude, and longitude of the place is in my phpmyadmin, but when I try to get it, using my code above, there is no output