Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

//create query
$Query = "SELECT * ";
$Query .= "FROM item";


//execute query
if(!($Result = pg_exec($Connection, $Query)))
{
print("Could not execute query: ");
print(pg_errormessage($Connection));
print("
\n");
exit;
}


//loop over each row
while($Row = pg_fetch_row($Result, $Row))
{
print("$Row[0]
\n");
}


// free the result and close the connection
pg_freeresult($Result);
pg_close($Connection);
?>


boolean pg_fieldisnull(integer result, integer row, string field)


The pg_fieldisnull function returns TRUE if the specified field is NULL. Fields are
counted from 0. See pg_exec for an example of use.


string pg_fieldname(integer result, integer field)


The pg_fieldname function returns the name of the field in the result set specified by the
field number, which starts counting at zero. See pg_exec for an example of use.


integer pg_fieldnum(integer result, string field)


The pg_fieldnum function returns the number of the field given its name. Numbering
begins with 0. If an error occurs, negative one (-1) is returned.


<?
print(pg_fieldnum($Result, "name"));
?>


integer pg_fieldprtlen(integer result, integer row, string field)


The pg_fieldprtlen function returns the printed length of a particular field value. You
may specify the field either by number, starting at zero, or by name.

Free download pdf