| <div class="well well-lg" id="searchBox"> |
| <h2 class="text-center">Pencarian Buku</h2> |
| <div class="text-center"> |
| <form role="form" method="GET"> |
| <select name="category"> |
| <option value="judul">Judul buku</option> |
| <option value="pengarang">Pengarang</option> |
| <option value="penerbit">Penerbit</option> |
| <option value="subyek">Kategori</option> |
| <option value="thn_terbit">Tahun terbit</option> |
| <option value="isbn">ISBN</option> |
| </select> |
| <input type="text" placeholder="Masukkan kata kunci" name="keyword"> |
| <input type="submit" name="search" value="cari" class="btn btn-info"> |
| </form> |
| </div> |
| </div> |
| |
| <table class="table table-hover table-bordered"> |
| <tr> |
| <th>No.</th> |
| <th>Judul</th> |
| <th>Pengarang</th> |
| <th>Penerbit</th> |
| <th>Kategori</th> |
| <th>Tahun terbit</th> |
| <th>No Rak</th> |
| <th>ISBN</th> |
| <th>Action</th> |
| </tr> |
| <?php |
| $sql="select * from buku,kategori where buku.id_kategori=kategori.id_kategori order by id_buku DESC"; |
| $query=mysql_query($sql); |
| $no=1; |
| while($row=mysql_fetch_array($query)){ |
| ?> |
| <?php |
| |
| if(isset($_GET['category'])&&isset($_GET['keyword'])){ |
| $category = $_GET['category']; |
| $keyword = $_GET['keyword']; |
| |
| |
| $sql = "SELECT * FROM buku WHERE $category LIKE '%$keyword%'"; |
| $result = mysqli_query($connection, $sql); |
| |
| $count=mysqli_num_rows($result); |
| }else{ |
| $sql = "SELECT * FROM buku;"; |
| $result = mysqli_query($connection, $sql); |
| |
| $count=mysqli_num_rows($result); |
| } |
| |
| |
| if($count>0){ |
| $number = 1; |
| |
| echo "<p>$count data ditampilkan.<p>"; |
| |
| while($row = mysqli_fetch_assoc($result)) { |
| $id = $row["id_buku"]; |
| echo "<tr> <td>" . $number. "</td><td> " . |
| $row["judul"]. "</td><td> " . |
| $row["pengarang"]."</td><td>". |
| $row["penerbit"]."</td><td>". |
| $row["nama_kategori"]."</td><td>". |
| $row["thn_terbit"]."</td><td>". |
| $row["deskripsi_fisik"]."</td><td>". |
| $row["isbn"]."</td><td>". |