Advertisement
azmicolejr

beli

Feb 8th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <?php
  2. if (isset($_GET['kategori']))
  3. {
  4. $kategori = $_GET['kategori'];
  5. }
  6.  
  7. include "config.php";
  8.  
  9. if ((isset($kategori)) =='')
  10. {
  11. $query = "SELECT * FROM barangtbl ORDER BY id DESC LIMIT 0,12";
  12. $hasil = mysql_query($query);
  13. $numrows = mysql_num_rows($hasil);
  14. }
  15. else
  16. {
  17. echo "
  18. <table width=\"100%\">
  19. <tr>
  20. <td align=\"center\"><b><font color=\"maroon\" size=\"2.5\">[ ".$_GET['kategori']." ]</b></font></td>
  21. </tr>
  22. </table>";
  23.  
  24. $query = "SELECT * FROM barangtbl WHERE kategori = '$kategori' ORDER BY id";
  25. $hasil = mysql_query($query);
  26. $numrows = mysql_num_rows($hasil);
  27. }
  28. ?>
  29.  
  30. <table cellpadding='10' cellspacing="2" align="center">
  31. <tr>
  32. <?php
  33. $kolom=3;
  34. $x = 0;
  35. if($numrows > 0)
  36. {
  37. while($data=mysql_fetch_array($hasil))
  38. {
  39. if ($x >= $kolom)
  40. {
  41. echo "</tr><tr>";
  42. $x = 0;
  43. }
  44. $x++;
  45. ?>
  46. <th>
  47. <div id="title">
  48. <a href="product.php?id=<?php echo $data['id']; ?>">
  49. <?php echo $data['judul_barang']; ?>
  50. </a>
  51. <br><br>
  52. </div>
  53.  
  54. <div id="image">
  55. <a href="product.php?id=<?php echo $data['id']; ?>">
  56. <img width='150' height='150' valign='top' border='1,5' src="product/<?php echo $data['gambar']; ?>" />
  57. </a>
  58. <br><br>
  59. </div>
  60.  
  61. <div id="price">
  62. <?php $hargarp = $data['harga'] ?>
  63. <?php echo "Rp " .number_format($hargarp, 0, ',', '.').",-" ?>
  64. <br><br>
  65. </div>
  66.  
  67. <div id="action">
  68. <?php
  69. if ($hasil==0)
  70. {
  71. echo "Stok kosong";
  72. }
  73. else
  74. {
  75. echo '
  76. <a href="add-to-cart.php?id='.$data['id'].'">
  77. <img src="images/buy.jpg"\ title="Beli" border="0" width=\"50\" height=\"30\">
  78. </a>
  79. <a href="product.php?id='.$data['id'].'">
  80. <img src="images/detail.jpg"\ title="Detail Barang" border="0" width=\"50\" height=\"30\">
  81. </a>';
  82. }
  83. ?>
  84. </div>
  85. <hr />
  86. </th>
  87. <?php
  88. }
  89. }
  90. ?>
  91. </tr>
  92. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement