0

i dont find to my error plese help me


this code i using to loading to php array

while($newarray = mysql_fetch_array($query))
	{
	
		
		$latt[$count] = $newarray['lat'];
		$lonn[$count] = $newarray['lon'];
		$userr[$count] = $newarray['user'];
	
			$count++;
		

	}

this part my javascript code

var cout= <?php echo $count ?>;
        var lat = new Array();
        var lon = new Array();
	var user = new Array();
				
	<?php $count =0; ?>
	
        var i;
	
       for ( 	var ii=0 ; ii<cout ; ii++)
	        {
		    <?php $count++ ?>
					
		     user[ii] = ("<?php echo $userr[$count]?>");
		     lat[ii] = ("<?php echo $latt[$count]?>");
		     lon[ii] = ("<?php echo $lonn[$count]?>");
						
		     var point = new GLatLng(lat[ii],lon[ii]);
		     map.setCenter(point, 10);
		     var marker = new GMarker(point);
		     map.addOverlay(marker);
		     GEvent.addListener(marker, "click", function()
		     {marker.openInfoWindowHtml(user);});
			}

error is given by just fist point. I want to do to get the coordinates of all databases. javascrpit array not working.

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by pritaeas
0

You cannot mix javascript and php like that. You need to create a php file that generates the complete javascript array definition.

0

this all my code

<?php

	$mysql_conn = mysql_connect("localhost","root","");
	if ( ! $mysql_conn ) die ("MySQL Connection is impossible!");

	mysql_select_db("gps_mapping" , $mysql_conn) 
		or die ("Database connection is impossible!" . mysql_error() );
		

	
	$query = mysql_query("SELECT user,lat,lon FROM current_coor");
		
	$count=0;
	
	while($newarray = mysql_fetch_array($query))
	{
	
		
		$latt[$count] = $newarray['lat'];
		$lonn[$count] = $newarray['lon'];
		$userr[$count] = $newarray['user'];
	
			$count++;
		

	}

	

	mysql_close($mysql_conn)
	

		?>
		
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>GPS Traffic Control System</title>
		<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key=ABQIAAAAWeIQuIHOFLuie4fLCqtaOBQQrVR1YlaVCiJYorVXbT_KF9qWyxRzN7YKWUUZqL7y9ckoHTJDtQn8lA" type="text/javascript"></script>
		<script type="text/javascript">

					
					
					
			
	
		var map;
		var route;
		var lastpoint;
		var header = '&lt;waypoints&gt;';
		var data = "";
		var footer = '&lt;/waypoints&gt;';

		function load() {
			if (GBrowserIsCompatible()) {   
				route = document.getElementById("route");
				map = new GMap2(document.getElementById("map"));
					
			var cout= <?php echo $count ?>;
			var lat = new Array();
			var lon = new Array();
			var user = new Array();
				
			<?php $count =0; ?>
			   var i;
			   for ( var ii=0 ; ii<cout ; ii++)
				{
				<?php $count++ ?>
					
		               user[ii] = ("<?php echo $userr[$count]?>");
		        	lat[ii] = ("<?php echo $latt[$count]?>");
				lon[ii] = ("<?php echo $lonn[$count]?>");
						
				var point = new GLatLng(lat[ii],lon[ii]);
				map.setCenter(point, 10);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				GEvent.addListener(marker, "click", function()
				{marker.openInfoWindowHtml(user);});
					
				
						
					}	
					
					}

			}

	</script>
	</head>

	<body bgcolor="#000000" onload="load()" onunload="GUnload()">
		<center>
			<table>
				<tr>
					<td><div id="map" style="width: 800px; height: 500px;"></div></td>
				</tr>
			</table>
		</center>
	</body>
</html>
0
<?php
  $mysql_conn = mysql_connect("localhost","root","");
  if ( ! $mysql_conn )
    die ("MySQL Connection is impossible!");
  
  mysql_select_db("gps_mapping" , $mysql_conn) or die ("Database connection is impossible!" . mysql_error() );
  $query = mysql_query("SELECT user,lat,lon FROM current_coor");
  while($newarray = mysql_fetch_array($query)) {
    $latt[] = $newarray['lat'];
    $lonn[] = $newarray['lon'];
    $userr[] = $newarray['user'];
  }
  mysql_close($mysql_conn);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>GPS Traffic Control System</title>
  <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key=ABQIAAAAWeIQuIHOFLuie4fLCqtaOBQQrVR1YlaVCiJYorVXbT_KF9qWyxRzN7YKWUUZqL7y9ckoHTJDtQn8lA" type="text/javascript"></script>
  <script type="text/javascript">
    var map;
    var route;
    var lastpoint;
    var header = '&lt;waypoints&gt;';
    var data = "";
    var footer = '&lt;/waypoints&gt;';
    
    var cout = <?php echo count($latt); ?>;
    var lat = new Array(<?php echo implode(',', $latt); ?>);
    var lon = new Array(<?php echo implode(',', $lonn); ?>);
    var user = new Array(<?php echo "'" . implode("','", $user) . "'"; ?>);
    
    function load() {
      if (GBrowserIsCompatible()) {
        route = document.getElementById("route");
        map = new GMap2(document.getElementById("map"));
        
        for ( var ii=0 ; ii < cout ; ii++) {
          var point = new GLatLng(lat[ii],lon[ii]);
          map.setCenter(point, 10);
          var marker = new GMarker(point);
          map.addOverlay(marker);
          GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(user[ii]); });		
        }	
      }
    }
  </script>
</head>
<body bgcolor="#000000" onload="load()" onunload="GUnload()">
  <center>
    <table>
      <tr>
        <td><div id="map" style="width: 800px; height: 500px;"></div></td>
      </tr>
    </table>
  </center>
</body>
</html>

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.