Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2. require 'db/koneksi.php';
  3. $record = array();
  4. if ($result = $db->query("SELECT * FROM data")) {
  5.     if ($result->num_rows) {
  6.         while ($row = $result->fetch_object()) {
  7.             $record = $row;
  8.         }
  9.         $result->free();
  10.     }
  11. }
  12.  
  13.  
  14.  ?>
  15.  
  16. <!DOCTYPE html>
  17. <html>
  18.     <head>
  19.         <meta charset="UTF-8">
  20.         <title>Tampil Data</title>
  21.     </head>
  22.     <body>
  23.     <?php
  24.     if (!count($record)) {
  25.         echo 'tidak ada data';
  26.     }
  27.      ?>
  28.         <table align="center" cellspacing="0" border="1">
  29.             <thead>
  30.                 <th>Nama</th>
  31.                 <th>Jenis Kelamin</th>
  32.                 <th>Alamat</th>
  33.                 <th>Kota</th>
  34.             </thead>
  35.             <tbody>
  36.             <?php
  37.             foreach ($record as $r) {
  38.            
  39.              ?>
  40.                 <tr>
  41.                     <td><?php echo $r->nama; ?></td>
  42.                     <td><?php echo $r->jenis_kelamin; ?></td>
  43.                     <td><?php echo $r->alamat; ?></td>
  44.                     <td><?php echo $r->kota; ?></td>
  45.                 </tr>
  46.             <?php } ?>
  47.             </tbody>
  48.         </table>
  49.     </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement