How to update through infowindow?
<p>I'm trying to update my database through clicking a label in the google map infowindow. The language I'm using is PHP.</p>

<p>I'm using dynamic data to update, meaning that every info window has a different value. So when I click on the label my database will auto increment by 1. It did give me the message of "You have donated" when I've clicked the label but my database was not updated. </p>

<pre><code>&lt;script type="text/javascript"&gt;
function initialize() {
//sg map
   var latlng = new google.maps.LatLng(1.3667, 103.8);
var myOptions = {
  zoom: 11,
  center: latlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
    };
var map = new google.maps.Map(document.getElementById("map_canvas"),
    myOptions);
</code></pre>

<p>This is the part where I retrieve the values from the database. This works fine.</p>

<pre><code>&lt;?php
$query = "SELECT * FROM standcharbranch";
$result = $mysqli-&gt;query($query);
while($branch = $result-&gt;fetch_array())
{
$amt = $branch['NumOfDonate'];
$totalAmt = $amt*0.05;

?&gt;  

//location marker   
var marker = new google.maps.Marker({
position: new google.maps.LatLng(&lt;?php echo $branch['latitude'];?&gt;,&lt;?php echo              $branch['longtitude'];?&gt;),
map: map,
title: "&lt;?php echo $branch['Location'];?&gt;",
icon: "./Images/sclogo.png"
});
</code></pre>

<p>This is the infowindow part where I'm setting the label that will be clicked to update the database. </p>

<pre><code>var infowindow = new google.maps.InfoWindow();
//Add an onclick event to the marker that will load the overlay.
google.maps.event.addListener(marker, 'click', function() {

var contentString = "&lt;?php echo $branch['Location'].'&lt;br/&gt;&lt;br/&gt;'.'$'.$totalAmt.'&lt;br/&gt;&lt;br/&gt;'.'&lt;label id=donateCharity onclick=charityDonate()&gt;Donate&lt;/label&gt;'?&gt;";

  infowindow.setContent(contentString);
  infowindow.open(map,this);

  });

&lt;?php
}

?&gt;
}
</code></pre>

<p>This is the update part, but it seems to have a problem here.</p>

<pre><code>function charityDonate(){

&lt;?php

// construct your SQL statement
$sql = "UPDATE standcharbranch SET NumOfDonate =".($branch['NumOfDonate']+1)." WHERE Location='".$branch['Location']."'";
$checkresult=$mysqli-&gt;query($sql);
if($checkresult){?&gt;
alert("You have donated");

&lt;?php
}
else if(!$checkresult){
?&gt;
alert("Failed to donated");
&lt;?php
}
$mysqli-&gt;close();
?&gt;
}


&lt;/script&gt;
</code></pre>
