-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkamar - versi asli baca tabel kategori.php
233 lines (181 loc) · 6.41 KB
/
kamar - versi asli baca tabel kategori.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php include('header.php'); ?>
<!-- Breadcrumb Section Begin -->
<section class="breadcrumb-option">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb__text">
<h4>Kamar</h4>
<div class="breadcrumb__links">
<a href="index.php">Home</a>
<span>Kamar</span>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Breadcrumb Section End -->
<!-- Shop Section Begin -->
<section class="shop spad">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="shop__product__option">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="shop__product__option__left">
<?php
if(isset($_GET['cari'])){
?>
Hasil Pencarian : <b><?php echo htmlspecialchars($_GET['cari']); ?></b>
<?php
}else{
?>
<p>Pilih kamar terbaikmu!</p>
<?php
}
?>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="shop__product__option__right">
<form action="" method="get">
<p>Sort by Price:</p>
<?php
if(isset($_GET['cari'])){
$c = "&cari=".$_GET['cari'];
?>
<input type="hidden" name="cari" value="<?php echo $_GET['cari']; ?>">
<?php
}else{
?>
<?php
}
?>
<select name="urutan" onchange="this.form.submit()">
<option <?php if(isset($_GET['urutan']) && $_GET['urutan'] == "termahal"){echo "selected='selected'";} ?> value="termahal">Termahal</option>
<option <?php if(isset($_GET['urutan']) && $_GET['urutan'] == "termurah"){echo "selected='selected'";} ?> value="termurah">Termurah</option>
</select>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<?php
$halaman = 9;
$page = isset($_GET["halaman"]) ? (int)$_GET["halaman"] : 1;
$mulai = ($page>1) ? ($page * $halaman) - $halaman : 0;
// $result = mysqli_query($koneksi, "SELECT * FROM kamar");
if(isset($_GET['urutan']) && $_GET['urutan'] == "termurah"){
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$result = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori and kamar_nama like '%$cari%' order by kamar_harga asc");
}else{
$result = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori order by kamar_harga asc");
}
}else{
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$result = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori and kamar_nama like '%$cari%' order by kamar_harga desc");
}else{
$result = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori order by kamar_harga desc");
}
}
$total = mysqli_num_rows($result);
$pages = ceil($total/$halaman);
if(isset($_GET['urutan']) && $_GET['urutan'] == "termurah"){
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$data = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori and kamar_nama like '%$cari%' order by kamar_harga asc LIMIT $mulai, $halaman");
}else{
$data = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori order by kamar_harga asc LIMIT $mulai, $halaman");
}
}else{
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$data = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori and kamar_nama like '%$cari%' order by kamar_harga desc LIMIT $mulai, $halaman");
}else{
$data = mysqli_query($koneksi,"select * from kamar,kategori where kategori_id=kamar_kategori order by kamar_harga desc LIMIT $mulai, $halaman");
}
}
$no =$mulai+1;
while($d = mysqli_fetch_array($data)){
?>
<div class="col-lg-4 col-md-6 col-sm-6">
<div class="product__item">
<?php if($d['kamar_foto1'] == ""){ ?>
<ul class="product__hover">
<li>
<a href="kamar_detail.php?id=<?php echo $d['kamar_id']; ?>">
<img src="gambar/sistem/kamar.png">
</a>
</li>
</ul>
<?php }else{ ?>
<ul class="product__hover">
<li>
<a href="kamar_detail.php?id=<?php echo $d['kamar_id']; ?>">
<img src="gambar/kamar/<?php echo $d['kamar_foto1'] ?>">
</a>
</li>
</ul>
<?php } ?>
<div class="product__item__text">
<h6><?php echo $d['kamar_nama'] ?></h6>
<a href="kamar_detail.php?id=<?php echo $d['kamar_id']; ?>" class="add-cart"><i class="fa fa-eye"></i> Lihat kamar</a>
<small class="text-muted"><?php echo $d['kategori_nama'] ?></small>
<h5><?php echo "Rp. ".number_format($d['kamar_harga']).",-"; ?></h5>
<div class="product__color__select">
<small class="text-muted"><?php echo $d['kategori_nama'] ?></small>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
<?php
if($total == 0){
?>
<center><h4>Belum ada kamar.</h4></center>
<?php
}
?>
<div class="row">
<div class="col-lg-12">
<div class="product__pagination">
<?php for ($i=1; $i<=$pages ; $i++){ ?>
<?php if($page==$i){ ?>
<a class="active"><?php echo $i; ?></a>
<?php }else{ ?>
<?php
if(isset($_GET['cari'])){
$cari = $_GET['cari'];
$c = "&cari=".$cari;
}else{
$c = "";
}
if(isset($_GET['urutan']) && $_GET['urutan'] == "harga"){
?>
<a href="?halaman=<?php echo $i; ?>&urutan=harga<?php echo $c ?>"><?php echo $i; ?></a>
<?php
}else{
?>
<a href="?halaman=<?php echo $i; ?><?php echo $c ?>"><?php echo $i; ?></a>
<?php
}
?>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Shop Section End -->
<?php include('footer.php'); ?>