Assigning a javascript array with PHP/Postgresql query values in a loop
So, I have a postgresql database and I'm querying a particular column's values and assigning each value to a javascript array. Now I have a javascript function which outputs this data on a map. When i test the array manually (Entering the respective array index one by one), it returns the output perfectly alright. But in a loop (When i want to output all at once), i can only see the first element's output. The rest of the array is simply ignored or there's an error. I don't understand where the mistake is. Here's the code:

	<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyC0HZ81Ea8Jy8fJ6zm6_uvPp8UhLg5mczo&sensor=true"></script>
	<script type="text/javascript" src="GeoJSON.js"></script>
	<script type="text/javascript" src="polygon.js"></script>


	<script type="text/javascript">

	var geojson_Polygon = new Array();

	function kaushik()
	{
	
		<?php
			require("header.php");

			$connection = pg_connect($full);
	
			if(!$connection)
			{
				pg_close($connection);

			}

			$result = pg_query($connection, "SELECT ogc_fid, ST_AsGeoJSON(wkb_geometry), name FROM features");
			if (!$result) 
			{
  				exit;
			}

			$i = 0;			
			while ($row = pg_fetch_row($result)) 
			{	
				echo "\n";
				echo "geojson_Polygon[$i] = $row[1];";
				echo "\n";
				echo "\n";
				$i++;
			}
		
		?>
		
		for (var j=0; j<317; j++)
		{
			showFeature(geojson_Polygon[j]);
		}
		
			
	}
	</script>


Assigning a javascript array with PHP/Postgresql query values in a loop
===

So, I have a postgresql database and I'm querying a particular column's values and assigning each value to a javascript array. Now I have a javascript function which outputs this data on a map. When i test the array manually (Entering the respective array index one by one), it returns the output perfectly alright. But in a loop (When i want to output all at once), i can only see the first element's output. The rest of the array is simply ignored or there's an error. I don't understand where the mistake is. Here's the code:

	<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyC0HZ81Ea8Jy8fJ6zm6_uvPp8UhLg5mczo&sensor=true"></script>
	<script type="text/javascript" src="GeoJSON.js"></script>
	<script type="text/javascript" src="polygon.js"></script>


	<script type="text/javascript">

	var geojson_Polygon = new Array();

	function kaushik()
	{
	
		<?php
			require("header.php");

			$connection = pg_connect($full);
	
			if(!$connection)
			{
				pg_close($connection);

			}

			$result = pg_query($connection, "SELECT ogc_fid, ST_AsGeoJSON(wkb_geometry), name FROM features");
			if (!$result) 
			{
  				exit;
			}

			$i = 0;			
			while ($row = pg_fetch_row($result)) 
			{	
				echo "\n";
				echo "geojson_Polygon[$i] = $row[1];";
				echo "\n";
				echo "\n";
				$i++;
			}
		
		?>
		
		for (var j=0; j<317; j++)
		{
			showFeature(geojson_Polygon[j]);
		}
		
			
	}
	</script>

