title: Google maps marker infowindow
body: <pre><code>&lt;?php
          //connect to your database ** EDIT REQUIRED HERE **
          mysql_connect("localhost","root","root"); //(host, username, password)
  
          //specify database ** EDIT REQUIRED HERE **
          mysql_select_db("Airport") or die("Unable to select database");
          //select which database we're using
          $query="select * from LondonHeathrowAirportArrivals ORDER BY id DESC";  
          // query string stored in a variable
          $rt=mysql_query($query);
          // query executed 
          echo mysql_error(); 
  
          while($nt=mysql_fetch_array($rt)){
              $counter=$counter+1;
              $angle=round($nt['angle'], -1);
          ?&gt;
          &lt;script type="text/javascript"&gt;
          function initialize() {
  
            var myLatlng = new google.maps.LatLng(51.48, -0.52);
            var myOptions = {
              zoom: 8,
              center: myLatlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            var flightPlanCoordinates = [
              path1, path2, path3, path4, path5, path6
            ];
  
            var flightPath = new google.maps.Polyline({
              path: flightPlanCoordinates,
              strokeColor: "#FF0000",
              strokeOpacity: 1.0,
              strokeWeight: 2
            });
  
            flightPath.setMap(map);
             for (i=1;i&lt;=1000;i++){
                var marker&lt;?= $nt['Flightnumber'] ?&gt; = new google.maps.Marker({
                    position:eval('myLatlng'+i),
                    map: map, 
                    title:eval('title'+i),
                    icon: eval('image'+i)
                }); 
                google.maps.event.addListener(marker&lt;?= $nt['Flightnumber'] ?&gt;, 'click', function() {
                   alert('&lt;?= $nt[Flightnumber] ?&gt;');
                  });
  
            }
          }
                  var myLatlng&lt;?php echo $counter ?&gt;= new google.maps.LatLng(&lt;?php echo $nt['Length'] ?&gt;,&lt;?php echo $nt['Breadth'] ?&gt;);
                  var image&lt;?php echo $counter ?&gt; = new google.maps.MarkerImage('img/plane&lt;?= $angle ?&gt;.png', new google.maps.Size(35, 35), new google.maps.Point(0,0), new google.maps.Point(0, 12));
                  var title&lt;?php echo $counter ?&gt; = "&lt;?= $nt[Flightnumber] ?&gt;";
                  var path1= new google.maps.LatLng(51.51,-0.60);
                  var path2= new google.maps.LatLng(51.50,-0.58);
                  var path3= new google.maps.LatLng(51.49,-0.57);
                  var path4= new google.maps.LatLng(51.48,-0.55);
                  var path5= new google.maps.LatLng(51.48,-0.53);
                  var path6= new google.maps.LatLng(51.48,-0.52);
              &lt;/script&gt;
              &lt;?php               
              }
          ?&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>Can someone please explain to me why when I click on diffrent marker i still get an alert which has the content of the last marker??? And I would be very grateful if anyone could change the code above to make the alert unique for each one... I've been stuck on this for hours and can't find a solution.</p>