scott_pgsql_employee_3php.htm |
Using For loop:
|
Source Code : scott_pgsql_employee_3.txt |
<?php / // show name of the fields $i = pg_num_fields($result); 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>"; // ---- 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>"; } else { echo "The query failed with the following error:<br />\n"; echo pg_last_error($db_handle); } pg_close($dbconn); ?> |
![]() |