I'm a beginner in this field and tried to display the PostGIS database data in localhost. I used select query in my code, so the table got displayed. I want to display the geographical points in a map overlay or in GeoMoose. I'm attaching the code which I used to display the table. Can anyone help me?
<!DOCTYPE html>
<html>
<head></head>
<body bgcolor="white">
<?php
class assets {
public $gid;
public $id;
public $name;
public $main;
public $asset_name;
public $assetname;
public $geom;
//Database Variables
public $connection;
public function __construct() {
$this->connection = pg_connect("host=localhost port=5432 dbname=postgis user=postgres password=1234") or print("cant connect");
}
public function __destruct() {
}
public function create() {
}
public function read() {
$result = pg_query($this->connection, "SELECT gid,id, name, main,asset_name,assetname,geom FROM assets");
if (!$result) {
echo "An error occured.\n";
exit;
} else {
echo "<table border=1>";
echo "<tr><td>gID</td><td>ID</td><td>Name</td>
<td>Main</td> <td>asset_name</td> <td>assetname</td> <td>geom</td></tr>";
while ($row = pg_fetch_row($result)) {
echo "<tr>";
echo "<td valign=top>".$row[0]."</td>";
echo "<td valign=top>".$row[1]."</td>";
echo "<td valign=top>".$row[2]."</td>";
echo "<td valign=top>".$row[3]."</td>";
echo "<td valign=top>".$row[4]."</td>";
echo "<td valign=top>".$row[5]."</td>";
echo "<td valign=top>".$row[6]."</td>";
echo "</tr>";
}
echo "</table>";
}
pg_close($this->connection);
}
public function update(){
}
public function delete(){
}
}
$myAssets = new assets();
$myAssets->read();
?>
</body>
</html>