note 17642 deleted from function.pg-fetch-array by zak

From: Date: Tue, 18 Dec 2001 18:17:24 +0000
Subject: note 17642 deleted from function.pg-fetch-array by zak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23137@lists.php.net to get a copy of this message
The correct way to loop through the result is to use pg_numrows. <html> <head><title>postgres query</title></head> <body> <table border="1"> <?php $connection = pg_connect("host=localhost dbname=mydb"); $result = pg_exec( $connection, "SELECT * FROM mydb"); for ( $i=0; $i < pg_numrows($result); $i++) { $row = pg_fetch_array($result, $i, $PGSQL_ASSOC); echo "<tr>"; foreach ( $row as $field ) { echo ("<td>" . $field . "</td>"); } echo "</tr>"; } ?> </table> </body> </html>

« previous php.notes (#23137) next »