justhrun

pejing.pehape

Aug 25th, 2014
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.49 KB | None | 0 0
  1. <?php
  2.         include "../include/connect.php";
  3.  
  4. //      init&parameter paging : begin
  5.         $href = $_SERVER["PHP_SELF"];
  6.  
  7.         if(isset($_GET['tdata'])) $tdata = $_GET['tdata'];
  8.         if(isset($_GET['tpage'])) $tpage = $_GET['tpage'];
  9.         if(isset($_GET['dpage'])) $dpage = $_GET['dpage'];
  10.  
  11.         $itemperpage = 5;
  12.         if (!isset($tpage) || !isset($dpage) || !isset($tdata)) {
  13.                 $query = "select count(*) from pasien";
  14.                 $result = mysql_query($query);
  15.                 list($tdata) = mysql_fetch_row($result);
  16.                 mysql_free_result($result);
  17.                 $tpage = ceil($tdata/$itemperpage);
  18.                 $dpage = 1;         // yg tampil pertama adalah first page
  19. //              $dpage = $tpage;    // yg tampil pertama adalah last page
  20.     }
  21.     $limit = ($dpage-1)*$itemperpage;
  22. // init&parameter paging : end
  23.  
  24.         $query = "select * from pasien order by kode_pasien limit $limit,$itemperpage";
  25.         $hasil = mysql_query($query);
  26. ?>
  27.  
  28. <div align="center" id="Printing" name="Printing"> <!-- tabel rata tengah -->
  29. <h2><u>Data Pasien Bersalin</u></h2>
  30. <!-- membuat tabel untuk menampilkan data -->
  31. <table width="939" border="1">
  32. <tr bgcolor="#33FF33"> <!-- <tr> = table rows -->
  33. <th width=27>#</th>
  34. <th width="111" scope="col">Kode Pasien </th> <!-- <th> = table header -->
  35. <th width="215" scope="col">Nama Pasien </th>
  36. <th width="191" scope="col">Tanggal Masuk </th>
  37. <th width="168" scope="col">Alamat </th>
  38. <th width="146" scope="col">Rincian</th>
  39. <th width="68" scope="col" colspan="2">Opsi</th>
  40. </tr>
  41. <?php //perulangan untuk menampilkan data dalam beberapa baris
  42.  
  43.         $no = $limit;
  44.         while ($baris = mysql_fetch_array($hasil)){
  45.                 $no++;
  46.                 $bg = $no%2 ? "bgcolor=#dadada" : "bgcolor=#eaeaea";
  47.                 echo "<tr $bg><td align=right>$no&nbsp;</td>
  48.                        <td>$baris[kode_pasien]</td>
  49.                        <td>$baris[nama_pasien]</td>
  50.                        <td>$baris[tgl_masuk]</td>
  51.                        <td>$baris[alamat_pasien]</td>
  52.                        <td><a >Lihat Rincian</a></td>
  53.                        <td><a ><img /></a></td>
  54.                        <td><a ><img src='../icon/hapus.png' border='0'/></a></td></tr>\n";
  55.         }
  56.         mysql_free_result($hasil);
  57.  
  58. // paging
  59.         echo "<tr><td colspan=8 align=center>";
  60.         echo "[ Total Data: $tdata] &nbsp; [ Page $dpage/$tpage ]<b>&nbsp; &nbsp; &nbsp;";
  61.  
  62.         for($startp = $dpage - 5; $startp <= $tpage; $startp++) {
  63.                 if($startp>0) break;
  64.         }
  65.  
  66.         if($startp>1) echo "<a href='$href?tdata=$tdata&tpage=$tpage&dpage=1'>&lt;&lt;</a>&nbsp; &nbsp; &nbsp;\n";
  67.         $prevp = $dpage-1;
  68.         if($prevp>0) echo  "<a href='$href?tdata=$tdata&tpage=$tpage&dpage=$prevp'>&lt;</a>&nbsp; &nbsp; &nbsp;\n";
  69.  
  70.         for($lastp = $startp; $lastp <= $tpage; $lastp++) {
  71.                 $angka = $lastp==$dpage ? "<font color=red>$lastp</font>" : "$lastp";
  72.                 echo "<a href='$href?tdata=$tdata&tpage=$tpage&dpage=$lastp'>$angka</a>&nbsp; &nbsp;\n";
  73.                 if($lastp>=$dpage+5) break;
  74.         }
  75.  
  76.         $nextp = $dpage+1;
  77.         if($nextp<$tpage) echo "&nbsp; &nbsp;<a href='$href?tdata=$tdata&tpage=$tpage&dpage=$nextp'>&gt;</a>\n";
  78.         if($lastp<$tpage) echo "&nbsp; &nbsp; &nbsp;<a href='$href?tdata=$tdata&tpage=$tpage&dpage=$tpage'>&gt;&gt;</a>\n";
  79.     echo "</b><br><br><input type='button' value='Print'></td></tr>
  80. </table>\n";
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment