Menampilkan Database ke Website
Pemrogaman Web
Sintak :
- Pada data_siswa.php :
<h1> Data SMK </h1>
<table border='1' width='700' height='150' cellpadding="7" cellspacing="0">
<tr>
<th>NIS</th><th>Nama Siswa</th><th>Jenis Kelamin</th>
<th>Tempat Lahir</th><th>Tanggal Lahir</th><th>Nama Ibu Kandung</th>
</tr>
<?php
include"conn/config.php";
$perintah="select * from tb_siswa";
$query=mysqli_query($koneksi,$perintah);
while($data=mysqli_fetch_row($query))
{
echo"
<tr>
<td>$data[0]</td> <td>$data[1]</td> <td>$data[2]</td>
<td>$data[3]</td> <td>$data[4]</td> <td>$data[5]</td>
</tr>
";
}
?>
- Pada config.php :
<?php
$hostname="localhost";
$username="root";
$password="";
$db_name="db_smk";
$koneksi=mysqli_connect($hostname,$username,$password,$db_name);
?>
Output :

Komentar
Posting Komentar