-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_product.php
179 lines (152 loc) · 6.21 KB
/
search_product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Services</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<div id="header">
<div class="container">
<div id="container" clear:both;>
<div class="login" style="height: 30px; float: right;">
<?php if (isset($_SESSION['username'])){ ?>
<p class="welcome">
Halo, Selamat Datang <?php echo $_SESSION['username']; ?>
<a href="process/logout_submit.php">Log Out</a>
</p>
<?php }else{ ?>
<form action="process/login_submit.php" method="post" class="member_frm_lgn">
<input type="text" name="username" placeholder="username" required>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login" >
<a href="register.php"><input type="button" value="Register"></a>
</form>
<?php } ?>
</div>
</div>
<img id="logo" src="images/logo.png">
<div id="menu">
<ul>
<li class="nav1"><a href="index.php">HOME</a></li>
<li class="nav2"><a href="news.php">NEWS</a></li>
<li class="nav3"><a href="products.php">PRODUCTS</a></li>
<li class="nav4"><a href="contact.php">CONTACT</a></li>
<li class="nav5"><a href="gallery.php">GALLERY</a></li>
</ul>
</div>
</div>
</div>
<!-- END HEADER -->
<div id="greenLine"></div>
<div id="content">
<div class="container">
<div class="top">
<form action="search_product.php" method="get">
<style>
.top{height: 25px;padding:10px;}
.top form{float:left; width: 250px;}
</style>
<input type="text" name="search" placeholder="cari artikel">
<input type="submit" value="search">
</form>
</div>
<?php
include "config/config.php";
include "functions/dbfunctions.php";
$search = $_GET['search'];
$view = 6;
$sql = "SELECT * FROM product_tbl WHERE name_product LIKE '%$search%' ";
$total=query_count($sql);
if ($total>6) {
if(isset($_GET['page'])){
$page_aktif = $_GET['page'];
}else{
$page_aktif = 1;
}
$awaldata = ($page_aktif-1)*$view;
$sql = "SELECT * FROM product_tbl WHERE name_product LIKE '%$search%' LIMIT $awaldata,$view";
}
$qproduct = $koneksi->query($sql);
$rowproduct = $qproduct->fetch_assoc();
do{
?>
<div class="product_item">
<div class="number_icon"><?php echo $rowproduct['id_product']?></div>
<h2 class="product_title"><?php echo $rowproduct['name_product']?></h2>
<a class="example-image-link" href="product/<?php echo $rowproduct['gambar_product']?>" data-lightbox="example-set" data-title="Click the right half of the image to move forward."><img width="150px" height="150px" src="product/<?php echo $rowproduct['gambar_product']?>"></a>
<p class="product_desc">
<?php echo substr($rowproduct['description_product'],0,110) ?>
</p>
<a href="product_detail.php?id_product=<?php echo $rowproduct['id_product']?>" class="detail_product">Read More</a>
</div>
<?php
}while($rowproduct = $qproduct->fetch_assoc());
?>
<?php if ($total>6) { ?>
<?php
// Jumlah data yang sebenarnya
$sqltotal = "SELECT * FROM product_tbl WHERE name_product LIKE '%$search%' ";
$qtotal = $koneksi->query($sqltotal);
$total_data = $qtotal->num_rows;
// hal yang didapat
$total_page = ceil($total_data/$view);
// ceil pembulatan ke atas
?>
<div class="pagination" style="padding-top: 10px; height:30px; clear:both; ">
<?php for ($i=1; $i<=$total_page ; $i++) {
if($i==$page_aktif){ ?>
<div class="pagelinkactive">
<?php echo $i; ?>
</div>
<?php } else{?>
<a href="?page=<?php echo $i; ?>&search=<?php echo $search; ?>" class="pagelink">
<?php echo $i; ?>
</a>
<?php }
}?>
</div>
<?php } ?>
</div>
<style>
.pagelinkactive{
background-color: #60b000;
color:#fff;
text-align: center;
height: 20px;
width: 25px;
display: block;
float: left;
border-radius: 3px;
margin-right: 5px;
margin-top: 50px;
}
.pagelink{
background-color: #000;
color:#fff;
text-align: center;
height: 20px;
width: 25px;
display: block;
float: left;
border-radius: 3px;
margin-top: 50px;
margin-right: 5px;
text-decoration: none;
}
.pagelink:hover{
background-color: #60b000;
}
</style>
<div id="footer">
<div class="container">
<p> Copyright © Your Company All Right Reserved</p>
</div>
</div>
<!-- <! END FOOTER -->
</div>
<script src="lightbox/js/jquery-1.11.0.min.js"></script>
<script src="lightbox/js/lightbox.js"></script>
</body>
</html>