home *** CD-ROM | disk | FTP | other *** search
Wrap
Postgres Result View This is a function to display a table for Postgres results. This this code in an include file, require it, and call ShowResults($result) whenever you need to see what your queries result in. <?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); } } ?>