Advertisement
cdsatrian

grid data with span and div

Sep 3rd, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <!doctype html>
  2. <head>
  3. <title>product</title>
  4. <style type="text/css">
  5. span.row {
  6.  width:100%;
  7.  display: table-row;
  8. }
  9. div.paging{
  10.  width:100%;
  11.  text-align:center;
  12.  padding:2px;
  13. }
  14.  
  15. div.box {
  16.  border:dashed 1px #eee;
  17.  text-align:center;
  18.  width:200px;
  19.  height:50px;
  20.  display: table-cell;
  21.  padding:2px;
  22. }
  23. img {
  24.   width:150px;
  25.   height:40px;
  26.   background-color:#ffc;
  27. }
  28. </style>
  29. <body>
  30. <?php
  31.   $row=2;
  32.   $column=2;
  33.   $batas=$row*$column;
  34.   $p=isset($_GET['p'])?$_GET['p']:0;
  35.   $data=array("satu","dua","tiga","empat","lima","enam","tujuh","delapan","sembilan","sepuluh");
  36.   $i=$batas*$p;
  37.   echo "<span class=\"row\">\n";
  38.   while(isset($data[$i])&&$i<($batas*($p+1))){
  39.     echo ($i%$column==0?"</span>\n<span>\n":"")."<div class=\"box\"><img src=\"\" alt=\"gambar ".$data[$i]."\"><br>".$data[$i]."</div>\n";
  40.     $i++;
  41.   }
  42.   echo "</span>\n";
  43. ?>
  44. <span class="row">
  45.   <div class="paging">
  46.   <?php
  47.     echo ($p>0)?"<a href=\"?p=".($p-1)."\">prev</a>":"prev";
  48.     echo " | ";
  49.     echo (($p+1)<count($data)/$batas)?"<a href=\"?p=".($p+1)."\">next</a>":"next";
  50.   ?>  
  51.   </div>
  52. </span>
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement