menampilkan Database dari mysql ke Browser

menampilkan Database dari mysql ke Browser

<html>
<head>
   <title>menampilkan data</title>
</head>
<body>
<h2> menampilkan data dari database</h2>

<?php

$host="localhost";
$username="root";
$password="";

$conn = mysql_connect($host,$username,$password);
 $c = mysql_select_db("siakadb");

if (!$conn){
    echo "koneksi ke server gagal oi.";
    exit();
}

$query="select nim,nama,umur,tinggi,berat,karya from mahasiswa order by nim";
$result= mysql_query($query);

if ($result) {

   ?>
   <h4><u>sistem Informasi akademi:</u></h4>
   <table border="1">
      <tr>
     <th width="80">nim</th>
     <th width="150">nama</th>
     <th width="8">umur</th>
     <th width="8">tinggi</th>
     <th width="8">berat</th>
     <th width="8">karya</th>
     </tr>
 <?php
while ($row=mysql_fetch_assoc($result)){
?>
   <tr>
       <?php
       $nim =$row[nim];
       $nama =$row[nama];
       $umur =$row[umur];
       $tinggi =$row[tinggi];
       $berat =$row[berat];
       $karya =$row[karya];
       ?>
       <td><?php echo $nim;?></td>
       <td><?php echo $nama;?></td>
       <td><?php echo $umur;?></td>
       <td><?php echo $tinggi;?></td>
       <td><?php echo $berat;?></td>
       <td><?php echo $karya;?></td>
   </tr>
  <?php
 }
 ?>
    </table>
  <?php
 mysql_free_result($result);

 }

mysql_close($conn);
?>
</body>
</html>

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. binarycomputer99 - All Rights Reserved
Template Created by Creating Website Published by Mas Template | Distributed By: BloggerBulk
Proudly powered by Blogger