Author: Gerard Samuel
Date: 20-06-02 07:44
Some php code with respect to postgresql has been changed lately, so here is an updated example....
I currently using php 4.2.1
<?php
$conn = pg_connect("dbname=test user=myuser");
if ($conn)
{
$result = pg_exec ($conn, 'select * from test');
if ($result)
{
echo pg_numrows($result) . ' rows to fetch' . "\n";
echo '<table border="1" width="50%">' . "\n";
while ($myrow = pg_fetch_array ($result))
{
echo '<tr><td>' . $myrow['id'] . '</td><td>' . $myrow['name'] . '</td></tr>' . "\n";
}
echo '</table>' . "\n";
}
else
{
echo 'read from test failed';
}
}
else
{
echo 'no connection';
}
?>
|
|