<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body align="center">
<?php
include "koneksi.php";
?>
<script type="text/javascript">
function delete_id(id)
{
if(confirm('Yakin mau dihapus datanya ?'))
{
window.location.href='delete.php?delete_id='+id;
}
}
</script>
<table border="1" cellpadding="5" cellspacing="0" align="center">
<tr>
<td bgcolor='#000FFF'>Id</td>
<td bgcolor='#000FFF'>Nama</td>
<td bgcolor='#000FFF'>Alamat</td>
<td bgcolor='#000FFF'>Tahun</td>
<td bgcolor='#000FFF'>Kelas</td>
<td bgcolor='#000FFF'>Rombel</td>
<td bgcolor='#000FFF'>Delete</td>
<td bgcolor='#000FFF'>Edit</td>
</tr>
<?php
$query = mysqli_query($dbconnect, "SELECT * FROM siswa order by id DESC")
or die (mysqli_error($dbconnect));
//menampilkan JUMLAH BARIS
echo "<br>";
$jumlah=mysqli_num_rows($query);
echo "Jumlah data ada : ".$jumlah;
echo "<br><br>";
//SELESAI MENAMPILKAN JUMLAH
while ($row = mysqli_fetch_array($query)) {
echo
"<tr>
<td align='center' bgcolor='#00FFFF'>{$row['id']}</td>
<td bgcolor='#00FFFF'>{$row['nama']}</td>
<td bgcolor='#00FFFF'>{$row['alamat']}</td>
<td bgcolor='#00FFFF'>{$row['tahun']}</td>
<td bgcolor='#00FFFF'>{$row['kelas']}</td>
<td bgcolor='#00FFFF'>{$row['rombel']}</td>
<td bgcolor='#00FFFF' align='center'><a href='javascript:delete_id($row[0])'>Delete</a></td>
<td align='center' bgcolor='#00FFFF'><a href=update.php?id={$row['id']}/>Edit</a></td>
</tr>\n";
}
?>
</table><br>
<?php
include "tglskg.php";
?>
</body>
<?
}
?>
</html>
----------------
Buat file bernama koneksi.php
isinya
-------------
<?php
$hostname = "localhost";
$username = "XXXXX";
$password = "XXXX";
$db = "id6587238_sekolah";
$dbconnect=mysqli_connect($hostname,$username,$password,$db);
if ($dbconnect->connect_error) {
die("Database connection failed: " . $dbconnect->connect_error);
}
?>
-----------------------
Tidak ada komentar:
Posting Komentar
Komentarlah dengan bijak no Spam