Here is an example of the code I am using:
<?php
include("functions.inc");
// Set the query
$query = "select id, title, author, date, description from article_info";
//Execute and get results
$query_result = pg_exec (setconn(), $query);
//Number of rows in result
$num_rows = pg_numrows($query_result);
//Output results by row
$counter = 0;
while ($counter < $num_rows) {
$result_array = pg_fetch_array($query_result, $counter);
$id = $result_array["id"];
echo ($id);
$counter++;
}
?>