Skip to content

Instantly share code, notes, and snippets.

@galihazizif
Last active November 8, 2017 11:46
Show Gist options
  • Save galihazizif/ef19961ac08f5a93c13a1209c376347c to your computer and use it in GitHub Desktop.
Save galihazizif/ef19961ac08f5a93c13a1209c376347c to your computer and use it in GitHub Desktop.
bukutamu/page/home.php
<?php
try{
$dbConfig = $config['db'];
$pdo = new PDO($dbConfig['dsn'],$dbConfig['username'],$dbConfig['password']);
$sql = " SELECT * FROM daftar_tamu";
$pds = $pdo->query($sql);
$data = $pds->fetchAll();
}catch(PDOException $e){
echo $e->getMessage();
exit();
}
?>
<h3>Selamat datang di halaman buku tamu</h3>
<p>Berikut ini data tamu yang telah mengisi buku tamu</p>
<?php if(count($data) > 0): ?>
<table>
<tr>
<td>ID</td>
<td>Nama</td>
<td>Alamat</td>
<td>Email</td>
</tr>
<?php foreach($data as $tamu): ?>
<tr>
<td><?=$tamu['id'] ?></td>
<td><?=$tamu['nama'] ?></td>
<td><?=$tamu['alamat'] ?></td>
<td><?=$tamu['email'] ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
Belum ada tamu
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment