<?php Function ShowResults($result) { if ($result) { $rows = pg_NumRows($result); $cols = pg_NumFields($result); echo("<table border=1>\n"); /* Create the headers */ echo("<tr>\n"); for($i = 0; $i < $cols; $i++) { printf("<th>%s</th>\n", pg_FieldName($result, $i)); } echo("</tr>"); for($j = 0; $j < $rows; $j++) { echo("<tr>\n"); for($i = 0; $i < $cols; $i++) { printf("<td>%s</td>\n", pg_result($result, $j, $i)); } echo("</tr>"); } echo("</table>"); } else { echo(pg_errormessage); } } ?>