echo" <table border='1'>";
//
for ($row = 0; $row < pg_num_rows($result); $row++) {
//embbedding for loop
echo "<tr/>";
for($y=0; $y < pg_num_fields($result) ; $y++)
{
$r2 = pg_fetch_result($result, $row, $y);
echo " <td class='td2'>".$r2."</td>";
} // nested for
echo "</tr>";
}
echo "</table>";