cara menampilkan data

Anfaul · Nov 6, 2016
Saya mau tanya min.. say amu menampilkan data ke dalam menu admin tpi error kaya gini

Notice: Undefined variable: conn in C:\xampp\htdocs\Zakat\admin\mod-amil\dataamil.php on line 3

Fatal error: Call to a member function prepare() on a non-object in C:\xampp\htdocs\Zakat\admin\mod-amil\dataamil.php on line 3

ini min script.nya
<?php 
try{
  $queryamil = $conn->prepare("SELECT * FROM amil");
  $queryamil->execute();
  $rsamil=$queryamil->fetch(PDO::FETCH_ASSOC);
}
catch (PDOException $e) {
  echo $e->getMessage();
}
?>
<style type="text/css">
body,td,th {
  color: #000;
}
</style>

<h3>Data amil</h3>
<a href="?mod=mod-amil/simpanamil">+Tambah Data</a>
<table width="100%" border="1" cellpadding="5" cellspacing="0">
  <tr>
    <th>No</th>
    <th>Id Amil</th>
    <th>Nama Amil</th>
    <th>Alamat Amil</th>
    <th>Aksi</th>
  </tr>
  <?php $no=1; do{ ?>
  <tr>
    <td><?php echo $no++; ?></td>
    <td><?php echo $rsamil['id_amil']; ?></td>
    <td><?php echo $rsamil['nama_amil']; ?></td>
    <td><?php echo $rsamil['alamat_amil']; ?></td>
    <td><a href="?mod=mod-amil/detilamil&id_amil=<?php echo $rsamil['id_amil']; ?>">Detil |</a>
    <a href="?mod=mod-amil/editamil&id_amil=<?php echo $rsamil['id_amil']; ?>">Edit|</a>
    <a href="?mod=mod-amil/aksiamil&id_amil=<?php echo $rsamil['id_amil']; ?>&del=y" onClick="return confirm('Apakah anda mau menghapus data <?php echo addslashes ($rsamil['nama_amil']);?>?')" >Hapus|</a></td>
  </tr>
  <?php }while($rsamil=$queryamil->fetch(PDO::FETCH_ASSOC)); ?>
</table>
Silahkan login untuk menjawab!