PageRenderTime 127ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/inc/home.php

https://github.com/budigutama/tes-repo
PHP | 304 lines | 287 code | 13 blank | 4 comment | 28 complexity | 2dd00a61103afafcf1581e71d3b0344c MD5 | raw file
  1. <?php
  2. $batas = 9;
  3. if(isset($_GET['halaman']))
  4. $halaman = $_GET['halaman'];
  5. if(empty($halaman)){
  6. $posisi = 0;
  7. $halaman = 1;
  8. }
  9. else{
  10. $posisi = ($halaman-1) * $batas;
  11. }
  12. if(isset($_POST['textcari'])){
  13. $sqlcari = "AND nama_produk LIKE '%$_POST[textcari]%'";
  14. }
  15. else
  16. $sqlcari = "";
  17. ?>
  18. <?php
  19. if (isset($_POST['urutkan'])){
  20. $urut=$_POST['urutkan'];
  21. $idk=$_POST['kate'];
  22. if ($idk==""){ $kat=""; }
  23. else { $kat="AND id_kategori='$idk'"; }
  24. if($urut=='produk_terlaris'){
  25. $title = "Produk Terlaku";
  26. $sqlproduk = "SELECT *,SUM(qty) as jumlah
  27. FROM detail_pembelian as a, detailproduk as b, produk as c
  28. WHERE a.id_detailproduk = b.id_detailproduk
  29. AND b.id_produk = c.id_produk
  30. $kat
  31. GROUP BY c.id_produk
  32. ORDER BY jumlah DESC
  33. LIMIT 9";
  34. }
  35. elseif($urut=='produk_diskon'){
  36. $title = "Produk Diskon";
  37. $sqlproduk = "SELECT * FROM produk
  38. WHERE diskon_produk > 0
  39. $kat
  40. GROUP BY id_produk order by diskon_produk desc
  41. LIMIT 9";
  42. }
  43. elseif($urut=='produk_lihat'){
  44. $title = "Produk Paling Banyak Dilihat";
  45. $sqlproduk = "SELECT * FROM produk
  46. WHERE viewcounter_produk > 0
  47. $kat
  48. GROUP BY id_produk order by viewcounter_produk desc
  49. LIMIT 9";
  50. }
  51. elseif($urut=='produk_terbaru'){
  52. $title = "Produk Terbaru";
  53. $sqlproduk = "SELECT * FROM produk a, detailproduk b
  54. WHERE a.id_produk=b.id_produk
  55. $kat
  56. GROUP BY b.id_produk
  57. order by tanggal_detailproduk desc
  58. LIMIT 9";
  59. }
  60. }
  61. elseif (isset($_GET['size'])){
  62. $size=$_GET['size'];
  63. $title = "Produk Size $size";
  64. $sqlproduk = "SELECT * FROM produk a, detailproduk b, ukuran c
  65. WHERE a.id_produk=b.id_produk
  66. AND b.id_ukuran=c.id_ukuran
  67. AND c.nama_ukuran='$size'
  68. GROUP BY a.id_produk
  69. LIMIT 9";
  70. }
  71. elseif (isset($_GET['warna'])){
  72. $warna=$_GET['warna'];
  73. $title = "Produk Warna $warna";
  74. $sqlproduk = "SELECT * FROM produk a, detailproduk b, warna c
  75. WHERE a.id_produk=b.id_produk
  76. AND b.id_warna=c.id_warna
  77. AND c.nama_warna='$warna'
  78. GROUP BY a.id_produk
  79. LIMIT 9";
  80. }
  81. elseif (isset($_GET['harga'])){
  82. $harga=$_GET['harga'];
  83. $title = "Produk Harga Rp.".substr($harga,14,7)."an";
  84. $sqlproduk = "SELECT * FROM produk a, detailproduk b
  85. WHERE a.id_produk=b.id_produk
  86. AND a.$harga
  87. GROUP BY a.id_produk
  88. LIMIT 9";
  89. }
  90. else
  91. {
  92. $title = "Produk";
  93. $sqlproduk = "SELECT * FROM produk a, detailproduk b
  94. WHERE a.id_produk=b.id_produk
  95. $sqlcari
  96. GROUP BY b.id_produk
  97. order by tanggal_detailproduk desc";
  98. }
  99. ?>
  100. <div class="center_title_bar" style="margin-bottom:20px;"><?php echo $title; ?></div>
  101. <div class="sorting"><?php include "inc/menu.php" ?></div>
  102. <?php
  103. if(isset($_POST['registrasi'])){
  104. if($_SESSION['string'] == $_POST['code']){
  105. $ncari = mysql_num_rows(mysql_query("SELECT *
  106. FROM member
  107. WHERE email_member = '$_POST[email]'"));
  108. if($ncari == 0){
  109. $verifikasi = md5(uniqid());
  110. mysql_query("INSERT INTO member VALUES(null, $_POST[kota], '$_POST[nama]', '$_POST[alamat]',
  111. '$_POST[telp]', '$_POST[kodepos]', '$_POST[email]', '".md5($_POST['password'])."',
  112. '".$verifikasi."', '0')") or die(mysql_error());
  113. //email
  114. emailregister($_POST[email],$_POST[nama],$_POST[alamat],$_POST[kota],$_POST[telp],$_POST[kodepos],$verifikasi);
  115. echo "<h3>Terima Kasih Anda Telah Melakukan Registrasi,<br /> Silahkan Verifikasi Account Anda di Email..</h3>";
  116. }
  117. else{
  118. echo "<h3>Sebelumnya Anda Telah Terdaftar !!!</h3>";
  119. }
  120. }
  121. else{
  122. echo "<h3> Kode Captca Tidak Sesuai !!</h3>";
  123. }
  124. }
  125. if(isset($_GET['code'])){
  126. if(mysql_num_rows(mysql_query("SELECT * FROM member WHERE verificationcode_member = '$_GET[code]' AND status_member = '0'")) == 1){
  127. mysql_query("UPDATE member
  128. SET status_member = '1'
  129. WHERE verificationcode_member = '$_GET[code]'");
  130. echo "<h3>Verifikasi Telah Dilakukan, Silahkan Login !!</h3>";
  131. }
  132. else{
  133. echo "<h3>Verifikasi Gagal !!</h3>";
  134. }
  135. }
  136. $tampil2 = mysql_query($sqlproduk) or die(mysql_error());
  137. $jmldata = mysql_num_rows($tampil2);
  138. $jmlhal = ceil($jmldata/$batas);
  139. if (isset($_POST['urutkan'])){
  140. $urut=$_POST['urutkan'];
  141. $idk=$_POST['kate'];
  142. if ($idk==""){ $kat=""; }
  143. else { $kat="AND id_kategori='$idk'"; }
  144. if($urut=='produk_terlaris'){
  145. $title = "Produk Terlaku";
  146. $sqlproduk = "SELECT *,SUM(qty) as jumlah
  147. FROM detail_pembelian as a, detailproduk as b, produk as c
  148. WHERE a.id_detailproduk = b.id_detailproduk
  149. AND b.id_produk = c.id_produk
  150. $kat
  151. GROUP BY c.id_produk
  152. ORDER BY jumlah DESC
  153. LIMIT 9";
  154. }
  155. elseif($urut=='produk_diskon'){
  156. $title = "Produk Diskon";
  157. $sqlproduk = "SELECT * FROM produk
  158. WHERE diskon_produk > 0
  159. $kat
  160. GROUP BY id_produk order by diskon_produk desc
  161. LIMIT 9";
  162. }
  163. elseif($urut=='produk_lihat'){
  164. $title = "Produk Paling Banyak Dilihat";
  165. $sqlproduk = "SELECT * FROM produk
  166. WHERE viewcounter_produk > 0
  167. $kat
  168. GROUP BY id_produk order by viewcounter_produk desc
  169. LIMIT 9";
  170. }
  171. elseif($urut=='produk_terbaru'){
  172. $title = "Produk Terbaru";
  173. $sqlproduk = "SELECT * FROM produk a, detailproduk b
  174. WHERE a.id_produk=b.id_produk
  175. $kat
  176. GROUP BY b.id_produk
  177. order by tanggal_detailproduk desc
  178. LIMIT 9";
  179. }
  180. }
  181. elseif (isset($_GET['size'])){
  182. $size=$_GET['size'];
  183. $title = "Produk Size $size";
  184. $sqlproduk = "SELECT * FROM produk a, detailproduk b, ukuran c
  185. WHERE a.id_produk=b.id_produk
  186. AND b.id_ukuran=c.id_ukuran
  187. AND c.nama_ukuran='$size'
  188. GROUP BY a.id_produk
  189. LIMIT 9";
  190. }
  191. elseif (isset($_GET['warna'])){
  192. $warna=$_GET['warna'];
  193. $title = "Produk Warna $warna";
  194. $sqlproduk = "SELECT * FROM produk a, detailproduk b, warna c
  195. WHERE a.id_produk=b.id_produk
  196. AND b.id_warna=c.id_warna
  197. AND c.nama_warna='$warna'
  198. GROUP BY a.id_produk
  199. LIMIT 9";
  200. }
  201. elseif (isset($_GET['harga'])){
  202. $harga=$_GET['harga'];
  203. $title = "Produk Harga Rp.".substr($harga,14,7)."an";
  204. $sqlproduk = "SELECT * FROM produk a, detailproduk b
  205. WHERE a.id_produk=b.id_produk
  206. AND a.$harga
  207. GROUP BY a.id_produk
  208. LIMIT 9";
  209. }
  210. else
  211. {
  212. $title = "Produk";
  213. $sqlproduk = "SELECT * FROM produk a, detailproduk b
  214. WHERE a.id_produk=b.id_produk
  215. $sqlcari
  216. GROUP BY b.id_produk
  217. order by nama_produk
  218. LIMIT $posisi, $batas";
  219. }
  220. $qproduk = mysql_query($sqlproduk) or die(mysql_error());
  221. $no = 0;
  222. $kolom=1;
  223. $i=0;
  224. $no = $posisi+1;
  225. while($dproduk = mysql_fetch_array($qproduk)){
  226. $qgbr=mysql_fetch_array(mysql_query("SELECT nama_gambar gbr from gambar
  227. WHERE id_produk=$dproduk[id_produk]"));
  228. $gbr=$qgbr['gbr'];
  229. ?>
  230. <div class="prod_box">
  231. <div class="center_prod_box">
  232. <a href="?page=detail&idb=<?php echo $dproduk['id_produk']; ?>">
  233. <div class="product_img">
  234. <img src="images/product/<?php echo $gbr; ?>" alt="" height="175" width="160" border="0" title="Klik Untuk Melihat detil" /></div>
  235. <div class="frame"></div>
  236. <?php
  237. if($dproduk['diskon_produk'] != 0){
  238. $col="#C36";
  239. $harga="Rp.".number_format($dproduk['harga_produk'],"2",".",",")." - Dis ".$dproduk['diskon_produk']."%";
  240. }
  241. else {
  242. $col="#666";
  243. $harga="Rp.".number_format(hargadiskon($dproduk['id_produk']),"2",".",",")."";
  244. }?>
  245. <div class="prod_price"><?php echo $dproduk['nama_produk']; ?></div>
  246. <div class="nama_prod" style="color:<?php echo $col;?>"><?php echo $harga; ?></div></a>
  247. </div>
  248. </div>
  249. <?php
  250. $i++;
  251. $no++;
  252. }
  253. ?>
  254. <div class="pagination">
  255. <?php
  256. // Link ke halaman sebelumnya (previous)
  257. if($halaman > 1){
  258. $prev=$halaman-1;
  259. echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$prev'>Prev</a></span> ";
  260. }
  261. else{
  262. echo "<span class=disabled>Prev</span> ";
  263. }
  264. // Tampilkan link halaman 1,2,3 ...
  265. $angka=($halaman > 3 ? " ... " : " ");
  266. for($i=$halaman-2;$i<$halaman;$i++)
  267. {
  268. if ($i < 1)
  269. continue;
  270. $angka .= "<a href='$_SERVER[PHP_SELF]?halaman=$i'>$i</a> ";
  271. }
  272. $angka .= "<span class=current>$halaman</span> ";
  273. for($i=$halaman+1;$i<($halaman+3);$i++)
  274. {
  275. if ($i > $jmlhal)
  276. break;
  277. $angka .= "<a href='$_SERVER[PHP_SELF]?halaman=$i'>$i</a> ";
  278. }
  279. $angka .= ($halaman+2<$jmlhal ? " ...
  280. <a href='$_SERVER[PHP_SELF]?halaman=$jmlhal'>$jmlhal</a> " : " ");
  281. echo "$angka ";
  282. // Link kehalaman berikutnya (Next)
  283. if($halaman < $jmlhal){
  284. $next=$halaman+1;
  285. echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?halaman=$next'>Next</a></span>";
  286. }
  287. else{
  288. echo "<span class=disabled>Next</span>";
  289. }
  290. ?>
  291. </div>