Varios demostraciones de uso de postgresql en distintos lenguajes de programación.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
614 B

3 years ago
<?php
$conn = pg_connect('host=localhost port=5432 dbname=bdd user=bdd password=bdd');
if (!$conn) {
echo 'Database connection failed!';
exit(1);
}
$result = pg_query($conn, 'SELECT * FROM turista');
if (!$result) {
echo 'SELECT failed: '.pg_last_error($conn);
exit(1);
}
echo '<table border=1><tr>';
for ($i = 0; $i < pg_num_fields($result); $i++) {
echo '<td>'.pg_field_name($result, $i).'</td>';
}
echo '</tr>';
while ($row = pg_fetch_row($result)) {
echo '<tr>';
for ($i = 0; $i < pg_num_fields($result); $i++) {
echo '<td>'.$row[$i].'</td>';
}
echo '</tr>';
}
echo '</table>';
pg_close($conn);
?>