I'm doing a database query with the php tag in the javascript code block.but I'm not getting results when I use the javascript variable.

In the code below, "location[i][0]" is a javascript variable.The query runs seamlessly when I don't use this variable.

google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() {

        infowindow.setContent('Bölge: ' + locations[i][4] + '<br/><br/>' + '<?php

        $query=mysqli_query($conn,"SELECT * FROM yemek WHERE konum_id='"+locations[i][0]+"'"); 
        while($result=mysqli_fetch_array($query)){
            echo $result['isim'];
        }

        ?>');
        infowindow.open(map, marker);

}

})(marker, i));

There may be typos.I tried it in many different ways but it was not successful.

0 Answers