<html>
<head><title>Web Database Sample Index</title>
</head> 
<body bgcolor=#ffffff>
<h2>Data from t_user</h2>
<?php
$database = pg_Connect ("dbname=数据库的名 user=postgres password= port=192.168.3.241");
$query = "select * from 表名";
$result = pg_exec ($database, $query);
if ($result) {
echo "Found these entries in the database:<br><p></p>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#00FFFF>字段名1</td>
<td align=center bgcolor=#00FFFF>字段名2</td>
</tr>";while ($r = pg_fetch_array($result)) {$字段名1(可以是其他变量名)= $r["字段名1"];
$字段名2(可以是其他变量名)= $r["字段名2"];echo "<tr>
<td>$字段名1(可以是其他变量名)</td>
<td>$字段名2(可以是其他变量名)</td>
</tr>";
}
echo "</table>";
} else {
echo "No data.";
}
?>
</body>
</html>