php
$kon = mysqli_connect(‘localhost’,’root’,’’);
$link = mysqli_select_db($kon,”toko_komik”) or die(mysqli_error());
<?php
include “db_connect.php”;
$query=mysqli_query ($kon, “SELECT * FROM tbperpus”)or die
(mysqli_error());
$jumlah = mysqli_num_rows($query);
echo “<html>”;
echo “<head>”;
echo “<link href=’style.css’ type=’text/css’ rel=’stylesheet’>”;
echo “</head>”;
echo “<title> Toko Komik </title>”;
echo “<body>”;
echo “<font color=’darkmagenta’ face=’Arial’ size=3><b><br>Koleksi
Bukuku</b></font><br><br>”;
echo “<a href=’add.php’ style=\”text-decoration: none\”><font
face=’tahoma’ size=’1'>Masukkan buku baru</font></a><br>”;
echo “<br><table border=\”0\” cellpadding=\”1\” cellspacing=\”1\”
bordercolor=\”blue\” bgcolor=\”white\”>
<tr bgcolor=’blue’ height=\”30\”><font color=’white’>
<th align=’center’><font color=’white’ face=’Arial’
size=2>No</font></th>
<th align=’center’><font color=’white’ face=’Arial’
size=2>Judul</font></th>
<th align=’center’><font color=’white’ face=’Arial’
size=2>Penulis</font></th>
<th align=’center’><font color=’yellow’ face=’Arial’
size=2>Ubah?</font></th>
</tr>”;
$j=0;
while ($row=mysqli_fetch_array($query)) {
echo “<tr><td align=’left’ bgcolor=’#657FFF’>”;
echo “<font face=’Arial’ size=1>”;
echo $j+1;
echo”</font>”;
echo”</td>”;
echo “<td align=’left’ bgcolor=’#E8D3DF’>”;
echo “<font face=’Arial’ size=1>”;
echo $row[“judul”];
echo”</font>”;
echo”</td>”;
echo “<td align=’left’ bgcolor=’#E8D3DF’>”;
echo “<font face=’Arial’ size=1>”;
echo $row[“penulis”];
echo”</font>”;
echo”</td>”;
echo”<td align=’left’ bgcolor=’#E8D3DF’>”;
echo “<a href=’delete.php?id=”.$row[‘id’].”’ style=\”text-decoration:
none\” title=\”Hapus\”><font face=’tahoma’ size=’1'>Hapus</font></a>
<a href=’edit.php?id=”.$row[‘id’].”’ style=\”text-decoration: none\”
title=\”Edit\”><font face=’tahoma’ size=’1'>Edit</font></a>”; $j++; }
echo”</table>”;
echo “</body>”;
echo “</html>”;
?>
Setelah itu copy paste kode berikut dan simpan dengan nama file
“add.php” pada file koleksiku yang telah dibuat
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8">
<title>Tambah buku baru</title>
<link href=”style.css” type=”text/css” rel=”stylesheet”>
</head>
<body>
<form action=”insert_koleksi.php” method=”POST”>
<font face=”Tahoma” color=”green” size=”1"><b><br>Masukkan buku
baru</b></font>
<table align=”left”>
<tr>
<td><font face=”Tahoma” color=”black” size=”2">judul</font></td>
<td>:</td>
<td><input type=”text” name=”judul” size=”30"></td>
</tr>
<tr>
<td><font face=”Tahoma” color=”black” size=”2">penulis</font></td>
<td>:</td>
<td><input type=”text” name=”penulis” size=”30"></td>
</tr>
<tr>
<td></td><td></td>
<td><input type=”submit” value=”Add”>
<font face=”Tahoma” color=”green” size=”2">
<a href=”index.php” style=”text-decoration:none”>back</font></a>
</td>
</tr>
</table>
</form>
</body>
</html>
kemudian copy paste kan lagi kode berikut dan simpan dengan
nama file “insert_koleksi.php” pada file koleksiku yang telah
dibuat
<?php
include “db_connect.php”;
$judul = $_POST[‘judul’];
$penulis = $_POST[‘penulis’];
if($query) {
?>
<script language=”JavaScript”>
document.location=’index.php’</script>
<?php
}
?>
kemudian copy paste kan lagi kode berikut dan simpan dengan
nama file “delete.php” pada file koleksiku yang telah dibuat
<?php
include “db_connect.php”;
$id = $_GET[‘id’];
kemudian copy paste kan lagi kode berikut dan simpan dengan
nama file “edit.php” pada file koleksiku yang telah dibuat
<?php
include “db_connect.php”;
$id = $_GET[‘id’];
$judul = $row[‘judul’];
$penulis = $row[‘penulis’];
echo “<html>”;
echo “<body>”;
echo “<font face=’tahoma’ color=’green’ size=4><b>Perbaiki
koleksi</b></font>”;
echo “<table align=’left’>”;
echo “<form method=\”post\” action=\”update.php?id=$id\”
enctype=’multipart/form-data’>”;
echo “<br>”;
echo “<tr><td><font face=’Tahoma’ color=’black’ size=2>judul
</font></td><td>:</td><td><input type=’text’ name=’judul’
value=’$judul’ size=’30'>
</td></tr>”;
echo “<tr><td><font face=’Tahoma’ color=’black’
size=2>penulis</font></td><td>:</td><td><input type=’text’
name=’penulis’ value=’$penulis’ size=’30'>
</td></tr>”;
Kemudian copy paste kan lagi kode berikut dan simpan dengan
nama file “update.php” pada file koleksiku yang telah dibuat
<?php
include “db_connect.php”;
$id = $_GET[‘id’];
$judul = $_POST[‘judul’];
$penulis = $_POST[‘penulis’];
if($query) {
?>
<script language=”JavaScript”>
document.location=’index.php’</script>
<?php
}
?>