如何使用PHP和'while'循环显示所有行?

时间:2015-09-13 10:38:57

标签: php

我试图逐行显示,但它显示此错误:

  

未定义的偏移量:0

这是我的代码:

<?php
    $host = "localhost";
    $user = "postgres";
    $password = "20152016";
    $db = "Projet";

    $con = pg_connect("host=$host dbname=$db user=$user password=$password")
        or die ("Could not connect to server\n");
?>

<?php
    $query = "SELECT ST_ASGeoJSON(geometry) FROM poi where type='batiment'";
    $result = pg_query($con, $query);
    while ($row = pg_fetch_assoc($result))
    {
        $data = array();
        echo $data[0];
    }
?>

0 个答案:

没有答案