fungsi pencarian

parent 9254886d
<?php <?php
require_once("koneksi.php"); require_once("koneksi.php");
include 'header.php'; include 'header.php';
global $sql;
$sql = mysqli_query($koneksi, "SELECT * FROM t_artikel ORDER BY tanggal_dibuat DESC limit 8");
?> ?>
<!-- breadcrumbs --> <!-- breadcrumbs -->
<div class="breadcrumbs"> <div class="breadcrumbs">
...@@ -19,6 +21,21 @@ ...@@ -19,6 +21,21 @@
} }
?> ?>
</ol> </ol>
<?php
if(isset($_POST['cari'])){
$cari = $_POST['search'];
$sql = mysqli_query($koneksi, "SELECT * FROM t_artikel WHERE judul_artikel LIKE '%$cari%' ORDER BY tanggal_dibuat");
}
?>
<div class="w3l_search">
<form action="" method="post">
<input type="search" name="search" placeholder="Cari Judul Artikel" required="">
<button type="submit" class="btn btn-default search" aria-label="Left Align" name="cari">
<i class="fa fa-search" aria-hidden="true"> </i>
</button>
<div class="clearfix"></div>
</form>
</div>
</div> </div>
</div> </div>
<!-- //breadcrumbs --> <!-- //breadcrumbs -->
...@@ -27,7 +44,6 @@ ...@@ -27,7 +44,6 @@
<div class="container"> <div class="container">
<div class="agile_top_brands_grids"> <div class="agile_top_brands_grids">
<?php <?php
$sql = mysqli_query($koneksi, "SELECT * FROM t_artikel ORDER BY tanggal_dibuat DESC limit 8");
while($data = mysqli_fetch_array($sql)){ while($data = mysqli_fetch_array($sql)){
?> ?>
<div class="col-md-6 top_brand_left"> <div class="col-md-6 top_brand_left">
......
<?php <?php
require_once("koneksi.php"); require_once("koneksi.php");
include 'header.php'; include 'header.php';
global $sql;
$sql = mysqli_query($koneksi, "SELECT * FROM t_buku ORDER BY isbn ASC LIMIT 24");
?> ?>
<!-- breadcrumbs --> <!-- breadcrumbs -->
<div class="breadcrumbs"> <div class="breadcrumbs">
...@@ -10,15 +12,30 @@ ...@@ -10,15 +12,30 @@
if (isset($_SESSION['pengunjung'])) { if (isset($_SESSION['pengunjung'])) {
echo ' echo '
<li><span><i class="fa fa-sign-in" aria-hidden="true"></i><a href="login.php"> Masuk</a></span></li> <li><span><i class="fa fa-sign-in" aria-hidden="true"></i><a href="login.php"> Masuk</a></span></li>
<li class="active">Keranjang Belanja</li> '; <li class="active">Daftar Buku</li> ';
} }
else { else {
echo ' echo '
<li><a href="index.php"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>Beranda</a></li> <li><a href="index.php"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>Beranda</a></li>
<li class="active">Keranjang Belanja</li> '; <li class="active">Daftar Buku</li> ';
} }
?> ?>
</ol> </ol>
<?php
if(isset($_POST['cari'])){
$cari = $_POST['search'];
$sql = mysqli_query($koneksi, "SELECT * FROM t_buku WHERE judul LIKE '%$cari%' ORDER BY isbn");
}
?>
<div class="w3l_search">
<form action="" method="post">
<input type="search" name="search" placeholder="Cari Judul Buku" required="">
<button type="submit" class="btn btn-default search" aria-label="Left Align" name="cari">
<i class="fa fa-search" aria-hidden="true"> </i>
</button>
<div class="clearfix"></div>
</form>
</div>
</div> </div>
</div> </div>
<!-- //breadcrumbs --> <!-- //breadcrumbs -->
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
session_destroy(); session_destroy();
header('location: index.php'); header('location: index.php');
}; };
global $sql;
$sql = mysqli_query($koneksi, "SELECT * FROM t_buku ORDER BY isbn ASC LIMIT 24");
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
...@@ -103,21 +101,6 @@ ...@@ -103,21 +101,6 @@
<div class="w3ls_logo_products_left"> <div class="w3ls_logo_products_left">
<h1><a href="about.php">Toko Buku Cemerlang</a></h1> <h1><a href="about.php">Toko Buku Cemerlang</a></h1>
</div> </div>
<?php
if(isset($_POST['cari'])){
$cari = $_POST['search'];
$sql = mysqli_query($koneksi, "SELECT * FROM t_buku WHERE judul LIKE '%$cari%' ORDER BY isbn");
}
?>
<div class="w3l_search">
<form action="" method="post">
<input type="search" name="search" placeholder="Cari Judul Buku" required="">
<button type="submit" class="btn btn-default search" aria-label="Left Align" name="cari">
<i class="fa fa-search" aria-hidden="true"> </i>
</button>
<div class="clearfix"></div>
</form>
</div>
<div class="clearfix"> </div> <div class="clearfix"> </div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment