// open a connection to the database server
$connection = pg_connect("host=localhost port=5432 dbname=voiphotline user=lmartin password=L2pRD9bn");
if (!$connection)
{
die("Could not open connection to database server");
}
// generate and execute a query
$query = "select * from members where city='Chula Vista' or city='San Diego'"; $result
= pg_query($connection, $query) or die("Error in query: $query. " .
pg_last_error($connection));
// get the number of rows in the resultset
// this is PG-specific
$rows = pg_num_rows($result);
// if records present
if ($rows > 0)
{
$r=0;
$c=0;
$rd=0;
// iterate through resultset
for ($i=0; $i<$rows; $i++)
{
if($rd % 2)
{ //this means if there is a remainder
$color="FF0000";
} else { //if there isn't a remainder we will do the else
$color="0000FF";
}
if($r > $c+3){$rd=$rd+1; echo ""; $c=$c+4;}
$row = pg_fetch_row($result, $i);
if($r < $r+3){
$r=$r+1;
?>
|
echo $row[0]; ?> |
|
echo $row[1]; ?>
echo $row[2]; ?>
echo $row[3]?> echo $row[4]; ?>, echo $row[5]; ?> link
echo $row[6]; ?>
|
|
|
}
}
echo "
";
}
// if no records present
// display message
else
{
?>
No data available.
}
// close database connection
pg_close($connection);
?>
Register Members echo $rows; ?>