Latihan 6 - Aplikasi Pemrograman Web - Edit Data
Pada Latihan 6 mempelajari mengedit data dan proses penyimpanannya.
<head>
<title>Aplikasi Buku Perpustakaan</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<table width=800 border=0 align=center>
<tr height=200 class="kotak5 gradient8">
<td>
<p align=left>
<font color=white size=6>
Aplikasi Buku Perpustakaan
</font>
</p>
</td>
</tr>
<tr height=50 class="kotak1 gradient7">
<td>
<div class="ketengah">
<!-- linear gradient -->
<?php
include "menu.php"
?>
</div>
</td>
</tr>
<tr height=200>
<td>
<image src="gambar/gerbang.jpg" width=800 height=300>
</td>
</tr>
<tr height=30 class="kotak3 gradient6">
<td>
<marquee scrollamount="4" onmouseover="this.stop()" onmouseout="this.start()" style="color: white;">
<font size="3"> <b>
Selamat Datang di Aplikasi Buku Perpustakaan SMKN 1 Panyingkiran
</b></font>
</marquee>
</td>
</tr>
<tr height=800 class="kotak4 gradient7" valign="top">
<td>
<br><br><br>
<center>
<font color=white size="4"><b>
EDIT DATA BUKU PERPUSTAKAAN
</font></b>
<br><br><br>
<?php
include "koneksi.php";
$kdbuku = $_GET['kdbuku'];
$query_mysql = mysql_query("SELECT * FROM buku WHERE kdbuku='$kdbuku'")or die(mysql_error());
$nomor = 1;
while($data = mysql_fetch_array($query_mysql)){
?>
<form action="buku-update.php" method="post">
<table align="center" width="700">
<tr bgcolor="lightgreen">
<td>Kdbuku</td>
<td bgcolor="blue" >
<input type="text" name="kdbuku" readonly value="<?php echo $data['kdbuku'] ?>">
</td>
</tr>
<tr bgcolor="lightgreen">
<td>ISBN</td>
<td><input type="text" name="isbn" value="<?php echo $data['isbn'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td>Judul</td>
<td><input type="text" name="judul" value="<?php echo $data['judul'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td>Pengarang</td>
<td><input type="text" name="pengarang" value="<?php echo $data['pengarang'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td>Penerbit</td>
<td><input type="text" name="penerbit" value="<?php echo $data['penerbit'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td></td>
<td>
<Button class=warna2 type="submit" value="Simpan Perubahan Data">
< Simpan Perubahan Data >
</button>
</td>
</tr>
</table>
</form>
<?php } ?>
</td>
</tr>
<tr height=200 class="kotak2 gradient8">
<td>
<p align=center>
<img src="gambar/logo.png" width="50" height="50"><br>
<font color=white size="4">
SMK Negeri 1 Panyingkiran
</font>
<br>
<font color=white size="2">
Jalan Kirapandak Panyingkiran Kabupaten Majalengka 45459
<br>
Created By : muchamadekisa@2019
</font>
</p>
</td>
</tr>
</table>
</body>
<?php
include 'koneksi.php';
$kdbuku = $_POST['kdbuku'];
$isbn = $_POST['isbn'];
$judul = $_POST['judul'];
$pengarang = $_POST['pengarang'];
$penerbit = $_POST['penerbit'];
mysql_query("UPDATE buku SET isbn='$isbn', judul='$judul', pengarang='$pengarang', penerbit='$penerbit' WHERE kdbuku='$kdbuku'");
header("location:buku-lihat.php?pesan=update");
?>
Pada Latihan 6 mempelajari mengedit data dan proses penyimpanannya.
buku-edit.php
<head>
<title>Aplikasi Buku Perpustakaan</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<table width=800 border=0 align=center>
<tr height=200 class="kotak5 gradient8">
<td>
<p align=left>
<font color=white size=6>
Aplikasi Buku Perpustakaan
</font>
</p>
</td>
</tr>
<tr height=50 class="kotak1 gradient7">
<td>
<div class="ketengah">
<!-- linear gradient -->
<?php
include "menu.php"
?>
</div>
</td>
</tr>
<tr height=200>
<td>
<image src="gambar/gerbang.jpg" width=800 height=300>
</td>
</tr>
<tr height=30 class="kotak3 gradient6">
<td>
<marquee scrollamount="4" onmouseover="this.stop()" onmouseout="this.start()" style="color: white;">
<font size="3"> <b>
Selamat Datang di Aplikasi Buku Perpustakaan SMKN 1 Panyingkiran
</b></font>
</marquee>
</td>
</tr>
<tr height=800 class="kotak4 gradient7" valign="top">
<td>
<br><br><br>
<center>
<font color=white size="4"><b>
EDIT DATA BUKU PERPUSTAKAAN
</font></b>
<br><br><br>
<?php
include "koneksi.php";
$kdbuku = $_GET['kdbuku'];
$query_mysql = mysql_query("SELECT * FROM buku WHERE kdbuku='$kdbuku'")or die(mysql_error());
$nomor = 1;
while($data = mysql_fetch_array($query_mysql)){
?>
<form action="buku-update.php" method="post">
<table align="center" width="700">
<tr bgcolor="lightgreen">
<td>Kdbuku</td>
<td bgcolor="blue" >
<input type="text" name="kdbuku" readonly value="<?php echo $data['kdbuku'] ?>">
</td>
</tr>
<tr bgcolor="lightgreen">
<td>ISBN</td>
<td><input type="text" name="isbn" value="<?php echo $data['isbn'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td>Judul</td>
<td><input type="text" name="judul" value="<?php echo $data['judul'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td>Pengarang</td>
<td><input type="text" name="pengarang" value="<?php echo $data['pengarang'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td>Penerbit</td>
<td><input type="text" name="penerbit" value="<?php echo $data['penerbit'] ?>"></td>
</tr>
<tr bgcolor="lightgreen">
<td></td>
<td>
<Button class=warna2 type="submit" value="Simpan Perubahan Data">
< Simpan Perubahan Data >
</button>
</td>
</tr>
</table>
</form>
<?php } ?>
</td>
</tr>
<tr height=200 class="kotak2 gradient8">
<td>
<p align=center>
<img src="gambar/logo.png" width="50" height="50"><br>
<font color=white size="4">
SMK Negeri 1 Panyingkiran
</font>
<br>
<font color=white size="2">
Jalan Kirapandak Panyingkiran Kabupaten Majalengka 45459
<br>
Created By : muchamadekisa@2019
</font>
</p>
</td>
</tr>
</table>
</body>
Tampilan buku.edit.php
- - - - -
buku-update.php
<?php
include 'koneksi.php';
$kdbuku = $_POST['kdbuku'];
$isbn = $_POST['isbn'];
$judul = $_POST['judul'];
$pengarang = $_POST['pengarang'];
$penerbit = $_POST['penerbit'];
mysql_query("UPDATE buku SET isbn='$isbn', judul='$judul', pengarang='$pengarang', penerbit='$penerbit' WHERE kdbuku='$kdbuku'");
header("location:buku-lihat.php?pesan=update");
?>
Tidak ada komentar:
Posting Komentar