Advertisement
cdsatrian

list product w. price

Oct 10th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.43 KB | None | 0 0
  1. <?php
  2. $YPATH="ypathfile";
  3. $gambar0="avatar.jpg";
  4. $PATH="galeri/cssgaleri";
  5. $YPATH="ypathfile";
  6. $PATH0="ypathcss";
  7. $kat=isset($_GET["kat"])?$_GET["kat"]:"";
  8. $where=(empty($kat))?"":"where `id-kategori`='$kat'";
  9. $query = mysql_query("SELECT * FROM `$tbproduk` $where");
  10. $jmldata = mysql_num_rows($query);
  11. ?>
  12. <link rel="stylesheet" type="text/css" href="<?php echo $PATH0."/".$css;?>" />
  13. <link rel="stylesheet" type="text/css" href="<?php echo $PATH; ?>/tips-basic.css" />
  14. <style type="text/css">
  15. .polos,.polos tr,.polos td {border:0px;}
  16. </style>
  17. <script type="text/javascript" src="<?php echo $PATH; ?>/jquery.tools.min.js"></script>
  18. <script type="text/javascript">
  19.   $(document).ready(function(){
  20.     $("#tools img[title]").tooltip('#tooltip');
  21.   });
  22.   function buka(url) {window.open(url, "window_baru", "width=800,height=600,left=320,top=100,resizable=1,scrollbars=1");}
  23. </script>
  24. <div style="position: absolute; top: 38px; left: 237px; display: none;" id="tooltip"></div>
  25. <div id="tools">
  26. <?php
  27.   $sql="SELECT * FROM `$tbproduk` WHERE `hits`>'0' ORDER BY RAND()";
  28.   $query=mysql_query($sql);
  29.   $jum=mysql_num_rows($query);
  30.     if($jum > 0){
  31.     //--------------------------------------------------------------------------------------------
  32.     $batas   = 8; // number of product per page
  33.     $column  = 4; // number of product per row
  34.     $page = isset($_GET['page'])?$_GET['page']:1;
  35.     $posawal=($page-1) * $batas;
  36.     $sql .= " LIMIT $posawal,$batas";
  37.     $q2  = mysql_query($sql);
  38.     $no = $posawal+1;
  39.     //--------------------------------------------------------------------------------------------                                 
  40.     $i=0;
  41.     echo "<table class=\"polos\">\n";
  42.     while ($w = mysql_fetch_array($q2)) {
  43.       echo ($i==0?"<tr>":"");
  44.         $i++;
  45.         $harga=RP($w["harga"]);
  46.         echo "<td align=\"center\">"
  47.             ."<a href='?mnu=produkdetailorder&id=".$w["id-produk"]."'>"
  48.             ."<img src='$YPATH/".$w["gambar"]."' border='0' alt='".$w["gambar"]."' width='120' height='100' "
  49.             ."title='".$w["nama-produk"]." (".KAT($tbkategori,$w["id-kategori"])."),Harga Rp.$harga<br>stok : ".$w[$ket2].". ".substr($w["keterangan"],0,100)."'>"
  50.             ."</a><br>"
  51.             ."Ukuran ".$w['ukuran']."<br>"
  52.             ."Harga Rp.$harga"
  53.             ."</td>";
  54.         if($i%$column==0){
  55.             echo "</tr>\n";
  56.         $i=0;      
  57.         }
  58.     }
  59.     if($i>0){
  60.       echo "<td colspan=\"".($column-$i)."\">&nbsp;</td></tr>\n";
  61.     }
  62.     echo "</table>";
  63.     //Langkah 3: Hitung total data dan page
  64.     if($jmldata>0){
  65.       $jmlhal  = ceil($jmldata/$batas);
  66.         echo "<div align=left>";
  67.         if($page > 1){
  68.             $prev=$page-1;
  69.             echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?page=$prev&mnu=produk'>« Prev</a></span> ";
  70.         }else{
  71.           echo "<span class=disabled>« Prev</span> ";
  72.         }
  73.         // Tampilkan link page 1,2,3 ...
  74.         for($i=1;$i<=$jmlhal;$i++){
  75.           if ($i != $page){
  76.             echo "<a href='$_SERVER[PHP_SELF]?page=$i&mnu=produk'>$i</a> ";
  77.           }else{
  78.             echo " <span class=current>$i</span> ";
  79.           }
  80.         }
  81.         // Link kepage berikutnya (Next)
  82.         if($page < $jmlhal){
  83.             $next=$page+1;
  84.             echo "<span class=prevnext><a href='$_SERVER[PHP_SELF]?page=$next&mnu=produk'>Next »</a></span>";
  85.         } else{
  86.           echo "<span class=disabled>Next »</span>";
  87.         }
  88.         echo "</div>";
  89.       }//if jmldata
  90.   }//if jum>0
  91.   echo "<p align=left>total $usaha <b>$jmldata</b> Data</p>";
  92. ?>
  93. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement