hi<br>I have a databse in postgresql and want to add it to open layer as lines in Geojson format.for this I write php codes . my file is close.php this is the code:<br><br><font style="color: rgb(153, 0, 0);" size="1">&lt;?php<br>
<br>   // Database connection settings<br>   define(&quot;PG_DB&quot;  , &quot;tehran&quot;);<br>   define(&quot;PG_HOST&quot;, &quot;localhost&quot;); <br>   define(&quot;PG_USER&quot;, &quot;postgres&quot;);<br>   define(&quot;PG_PORT&quot;, &quot;5432&quot;); <br>
   define(&quot;TABLE&quot;,  &quot;close&quot;);<br><br>     ?&gt;<br><br>&lt;?php<br><br>        $sql = &quot;SELECT gid, ST_AsGeoJSON(the_geom) AS geojson, length(the_geom) AS length FROM .TABLE &quot; ; <br>                    <br>
   <br>   // Connect to database<br>   $dbcon = pg_connect(&quot;dbname=&quot;.PG_DB.&quot; host=&quot;.PG_HOST.&quot; user=&quot;.PG_USER);<br><br>   // Perform database query<br>   $query = pg_query($dbcon,$sql); <br>   <br>
?&gt;<br><br>&lt;?php<br><br>   // Return streets as GeoJSON<br>   $geojson = array(<br>      &#39;type&#39;      =&gt; &#39;FeatureCollection&#39;,<br>      &#39;features&#39;  =&gt; array()<br>   ); <br>  <br>   // Add edges to GeoJSON array<br>
   while($edge=pg_fetch_assoc($query)) {  <br><br>      $feature = array(<br>         &#39;type&#39; =&gt; &#39;Feature&#39;,<br>         &#39;geometry&#39; =&gt; json_decode($edge[&#39;geojson&#39;], true),<br>         &#39;crs&#39; =&gt; array(<br>
            &#39;type&#39; =&gt; &#39;EPSG&#39;,<br>            &#39;properties&#39; =&gt; array(&#39;code&#39; =&gt; &#39;4326&#39;)<br>         ),<br>         &#39;properties&#39; =&gt; array(<br>            &#39;id&#39; =&gt; $edge[&#39;id&#39;],<br>
            &#39;length&#39; =&gt; $edge[&#39;length&#39;]<br>         )<br>      );<br>      <br>      // Add feature array to feature collection array<br>      array_push($geojson[&#39;features&#39;], $feature);<br>   }<br>
    <br>   // Close database connection<br>   pg_close($dbcon);<br><br>   // Return  result<br>   header(&#39;Content-type: application/json&#39;,true);<br>   echo json_encode($geojson);<br>   <br>?&gt;<br></font><br><br>
then  I add a layers to openlayers:this is the code:<br><pre> <span class="nx">json_layer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">OpenLayers</span><span class="p">.</span><span class="nx">Layer</span><span class="p">.</span><span class="nx">Vector</span><span class="p">(</span><span class="s2">&quot;GeoJSON&quot;</span><span class="p">,</span> <span class="p">{</span>
              <span class="nx">strategies</span><span class="o">:</span> <span class="p">[</span><span class="k">new</span> <span class="nx">OpenLayers</span><span class="p">.</span><span class="nx">Strategy</span><span class="p">.</span><span class="nx">Fixed</span><span class="p">()],</span>
                <span class="nx">protocol</span><span class="o">:</span> <span class="k">new</span> <span class="nx">OpenLayers</span><span class="p">.</span><span class="nx">Protocol</span><span class="p">.</span><span class="nx">HTTP</span><span class="p">({</span>
                                 url: &quot;./php/test.php&quot;,<span class="nx"></span><span class="p"></span>
                              <span class="nx">format</span><span class="o">:</span> <span class="k">new</span> <span class="nx">OpenLayers</span><span class="p">.</span><span class="nx">Format</span><span class="p">.</span><span class="nx">GeoJSON</span><span class="p">()</span><br>
 <br> <span class="p">})</span>
              <span class="p">});</span>

  <span class="c1">// Add our vector layer to the map</span>
  <span class="nx">map</span><span class="p">.</span><span class="nx">addLayer</span><span class="p">(</span><span class="nx">json_layer</span><span class="p">);</span>
</pre>but I dont see any line in the result of openlayers in the browser.projection of my database is4326 and for openlayers is 900913.<br><br>I have added the following lines to the openlayers codes but it doesnt works yet:<br>
<br><pre>internalProjection: epsg_900913,<br>  externalProjection: epsg_4326</pre>
<br>what is wrong in the php or openlayers code?<br>who can help me?<br>I have confused with this problem for some weeks.<br>thanks<br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>