PX : code

Postgres Result View by Nathan Straz
Download this code


<?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);
  }
}
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.