Error: Failed to connect to database.";
} else {
// Query to get animals
$result = pg_query($dbconn, "SELECT name, species, family FROM animals");
if (!$result) {
echo "
Error: Query failed.
";
} else {
echo '
';
echo '
Name
Species
Family
';
echo '';
while ($row = pg_fetch_assoc($result)) {
echo '
';
echo '
' . htmlspecialchars($row['name']) . '
';
echo '
' . htmlspecialchars($row['species']) . '
';
echo '
' . htmlspecialchars($row['family']) . '
';
echo '
';
}
echo '
';
}
// Close connection (optional)
pg_close($dbconn);
}
?>