note 31467 deleted from function.pg-query by cmb
| From: | cmb@php.net | Date: | Mon, 09 Aug 2021 13:51:09 +0000 |
| Subject: | note 31467 deleted from function.pg-query by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216762@lists.php.net to get a copy of this message | ||
Note Submitter: yoshinariatsuo at yahoo dot com
----
create table from pg_query results.. hope it helps newbies...
function table_create($result)
{
$numrows = pg_num_rows($result);
$fnum = pg_num_fields($result);
echo "<table border width='100%'>";
echo "<tr>";
for ($x = 0; $x < $fnum; $x++) {
echo "<td><b>";
echo strtoupper(pg_field_name($result, $x));
echo "</b></td>";
}
echo "</tr>";
for ($i = 0; $i < $numrows; $i++) {
$row = pg_fetch_object($result, $i);
echo "<tr align='center'>";
for ($x = 0; $x < $fnum; $x++) {
$fieldname = pg_field_name($result, $x);
echo "<td>";
echo $row->$fieldname;
echo "</td>";
}
echo"</tr>";
}
echo "</table>";
return 0;
}