Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET['kategori']))
- {
- $kategori = $_GET['kategori'];
- }
- include "config.php";
- if ((isset($kategori)) =='')
- {
- $query = "SELECT * FROM barangtbl ORDER BY id DESC LIMIT 0,12";
- $hasil = mysql_query($query);
- $numrows = mysql_num_rows($hasil);
- }
- else
- {
- echo "
- <table width=\"100%\">
- <tr>
- <td align=\"center\"><b><font color=\"maroon\" size=\"2.5\">[ ".$_GET['kategori']." ]</b></font></td>
- </tr>
- </table>";
- $query = "SELECT * FROM barangtbl WHERE kategori = '$kategori' ORDER BY id";
- $hasil = mysql_query($query);
- $numrows = mysql_num_rows($hasil);
- }
- ?>
- <table cellpadding='10' cellspacing="2" align="center">
- <tr>
- <?php
- $kolom=3;
- $x = 0;
- if($numrows > 0)
- {
- while($data=mysql_fetch_array($hasil))
- {
- if ($x >= $kolom)
- {
- echo "</tr><tr>";
- $x = 0;
- }
- $x++;
- ?>
- <th>
- <div id="title">
- <a href="product.php?id=<?php echo $data['id']; ?>">
- <?php echo $data['judul_barang']; ?>
- </a>
- <br><br>
- </div>
- <div id="image">
- <a href="product.php?id=<?php echo $data['id']; ?>">
- <img width='150' height='150' valign='top' border='1,5' src="product/<?php echo $data['gambar']; ?>" />
- </a>
- <br><br>
- </div>
- <div id="price">
- <?php $hargarp = $data['harga'] ?>
- <?php echo "Rp " .number_format($hargarp, 0, ',', '.').",-" ?>
- <br><br>
- </div>
- <div id="action">
- <?php
- if ($hasil==0)
- {
- echo "Stok kosong";
- }
- else
- {
- echo '
- <a href="add-to-cart.php?id='.$data['id'].'">
- <img src="images/buy.jpg"\ title="Beli" border="0" width=\"50\" height=\"30\">
- </a>
- <a href="product.php?id='.$data['id'].'">
- <img src="images/detail.jpg"\ title="Detail Barang" border="0" width=\"50\" height=\"30\">
- </a>';
- }
- ?>
- </div>
- <hr />
- </th>
- <?php
- }
- }
- ?>
- </tr>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement