pg_emp_fetch_result1.txt, pg_emp_fetch_result1.php
Script used: to get field name

echo" <table border='1'><tr>";
for ($j = 0; $j < $i; $j++) {
echo "<td class='td1'>";
$fieldname = pg_field_name($result, $j);
echo $fieldname." </td>";
}
echo "</tr></table>";
 

Scxript used

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>";