<?php
$dbcon = pg_connect("host='localhost' user='abi' password='abi' dbname='abi'");
// Cek Koneksi Ke Server Database
if ($dbcon) // Jika Ada Koneksi
{
echo "Koneksi Database Sukses";
}
else
{
echo "Koneksi Database Gagal";
}
echo"<br>";
$query = "SELECT * FROM news";
$result = pg_query($dbcon, $query) or die('Query failed: ' . pg_last_error());
// output result
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
echo "Id: " . $line['id_berita'] . " Judul: " . $line['judul_berita'] . "<br/>";
}
// free result
pg_free_result($result);
// close connection
pg_close($dbcon);
?>
Penjelasan :
1. Nama Database : news
2. Query yang ingin ditampilkan : id_berita dan judul_berita
Semoga Membantu..
EmoticonEmoticon