My gmap page turns blank after inserting php code into the infowindow content.
google.maps.event.addListener(noi, 'mouseover', function() {
var infowindow = new google.maps.InfoWindow({
content: '<?php
if ($count==0){
echo "No Open Tickets";
}
else{
echo "<table>";
foreach ($NOIcompliancearray as $SLA_Compliance=>$count) {
$Npath = $Nimages[$SLA_Compliance];
echo "<tr>";
echo "<td><a href='city.php?city=Noida&compliance=".$SLA_Compliance."'><img src='IndiaImages/".$Npath."' title='".$SLA_Compliance."' ></td>";
echo "<td>".$count."</td>";
echo "</tr>";
}
echo "</table>";
}
?>'
size: new google.maps.Size(100,100),
});
google.maps.event.addListener(noi, 'mouseover', function() {
infowindow.open(map,noi);
setTimeout(function() { infowindow.close(map, noi) }, 5000);
});
If i replace php code with some static content it works fine. Also, when I tried opening the webpage source code, it gives me result which i wanted to see in the info window. I am not sure where I am making mistake.
output from the webpage source code: content:
'<table><tr><td><a href='city.php?city=Noida&compliance=A'><img src='IndiaImages/Circle_Red.gif' title='A' ></td><td>3</td></tr><tr><td><a href='city.php?city=Noida&compliance=C'><img src='IndiaImages/Circle_Yellow.gif' title='C' ></td><td>10</td></tr></table>Noida'
Kindly help me understand the mistake and to mitigate the problem.
Look at the function
with php you get
The first
'
generated byphp
will interpreted as end of the string the rest will be in html source. you can see it but ignored by the function.So don't use
'
in that kind of code.escape the
"
sign insteadescape
"
look here