Latihan 8 - Aplikasi Pemrograman Web - Mencari Data
Pada Latihan 8 ini mempelajari langkah untuk mencari data di database
<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>
PENCARIAN DATA BUKU PERPUSTAKAAN
</font></b>
<br><br><br>
<?php
include 'koneksi.php';
?>
<table border="1" width="700" align="center">
<tr bgcolor="lightgreen">
<td>Cari Data Buku</td>
<td>
<form action="buku-cari.php" method="get">
<input type="text" name="cari" width="700">
</td>
</tr>
<tr bgcolor="lightgreen">
<td></td>
<td><button class=warna2 type="submit" value="cari">< Cari Data Buku ></button>
</td>
</tr>
</form>
</table>
<br><br>
<font color="white">
<?php
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
echo "<b>HASIL PENCARIAN : ".$cari."</b>";
}
?>
</font>
<table border="1" width="700" align="center">
<tr bgcolor="lightgrey">
<th>No</th>
<th>Kdbuku</th>
<th>ISBN</th>
<th>Judul</th>
<th>Pengarang</th>
<th>Penerbit</th>
</tr>
<?php
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$data = mysql_query("select * from buku where kdbuku like '%".$cari."%'");
}else{
$data = mysql_query("select * from buku");
}
$no = 1;
while($d = mysql_fetch_array($data)){
?>
<tr bgcolor="lightgreen">
<td><?php echo $no++; ?></td>
<td><?php echo $d['kdbuku']; ?></td>
<td><?php echo $d['isbn']; ?></td>
<td><?php echo $d['judul']; ?></td>
<td><?php echo $d['pengarang']; ?></td>
<td><?php echo $d['penerbit']; ?></td>
</tr>
<?php } ?>
</table>
</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>
Output setelah pencarian data :
Pada Latihan 8 ini mempelajari langkah untuk mencari data di database
<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>
PENCARIAN DATA BUKU PERPUSTAKAAN
</font></b>
<br><br><br>
<?php
include 'koneksi.php';
?>
<table border="1" width="700" align="center">
<tr bgcolor="lightgreen">
<td>Cari Data Buku</td>
<td>
<form action="buku-cari.php" method="get">
<input type="text" name="cari" width="700">
</td>
</tr>
<tr bgcolor="lightgreen">
<td></td>
<td><button class=warna2 type="submit" value="cari">< Cari Data Buku ></button>
</td>
</tr>
</form>
</table>
<br><br>
<font color="white">
<?php
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
echo "<b>HASIL PENCARIAN : ".$cari."</b>";
}
?>
</font>
<table border="1" width="700" align="center">
<tr bgcolor="lightgrey">
<th>No</th>
<th>Kdbuku</th>
<th>ISBN</th>
<th>Judul</th>
<th>Pengarang</th>
<th>Penerbit</th>
</tr>
<?php
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$data = mysql_query("select * from buku where kdbuku like '%".$cari."%'");
}else{
$data = mysql_query("select * from buku");
}
$no = 1;
while($d = mysql_fetch_array($data)){
?>
<tr bgcolor="lightgreen">
<td><?php echo $no++; ?></td>
<td><?php echo $d['kdbuku']; ?></td>
<td><?php echo $d['isbn']; ?></td>
<td><?php echo $d['judul']; ?></td>
<td><?php echo $d['pengarang']; ?></td>
<td><?php echo $d['penerbit']; ?></td>
</tr>
<?php } ?>
</table>
</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>
Output setelah pencarian data :
Tidak ada komentar:
Posting Komentar