Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "../include/connect.php";
- // init¶meter paging : begin
- $href = $_SERVER["PHP_SELF"];
- if(isset($_GET['tdata'])) $tdata = $_GET['tdata'];
- if(isset($_GET['tpage'])) $tpage = $_GET['tpage'];
- if(isset($_GET['dpage'])) $dpage = $_GET['dpage'];
- $itemperpage = 5;
- if (!isset($tpage) || !isset($dpage) || !isset($tdata)) {
- $query = "select count(*) from pasien";
- $result = mysql_query($query);
- list($tdata) = mysql_fetch_row($result);
- mysql_free_result($result);
- $tpage = ceil($tdata/$itemperpage);
- $dpage = 1; // yg tampil pertama adalah first page
- // $dpage = $tpage; // yg tampil pertama adalah last page
- }
- $limit = ($dpage-1)*$itemperpage;
- // init¶meter paging : end
- $query = "select * from pasien order by kode_pasien limit $limit,$itemperpage";
- $hasil = mysql_query($query);
- ?>
- <div align="center" id="Printing" name="Printing"> <!-- tabel rata tengah -->
- <h2><u>Data Pasien Bersalin</u></h2>
- <!-- membuat tabel untuk menampilkan data -->
- <table width="939" border="1">
- <tr bgcolor="#33FF33"> <!-- <tr> = table rows -->
- <th width=27>#</th>
- <th width="111" scope="col">Kode Pasien </th> <!-- <th> = table header -->
- <th width="215" scope="col">Nama Pasien </th>
- <th width="191" scope="col">Tanggal Masuk </th>
- <th width="168" scope="col">Alamat </th>
- <th width="146" scope="col">Rincian</th>
- <th width="68" scope="col" colspan="2">Opsi</th>
- </tr>
- <?php //perulangan untuk menampilkan data dalam beberapa baris
- $no = $limit;
- while ($baris = mysql_fetch_array($hasil)){
- $no++;
- $bg = $no%2 ? "bgcolor=#dadada" : "bgcolor=#eaeaea";
- echo "<tr $bg><td align=right>$no </td>
- <td>$baris[kode_pasien]</td>
- <td>$baris[nama_pasien]</td>
- <td>$baris[tgl_masuk]</td>
- <td>$baris[alamat_pasien]</td>
- <td><a >Lihat Rincian</a></td>
- <td><a ><img /></a></td>
- <td><a ><img src='../icon/hapus.png' border='0'/></a></td></tr>\n";
- }
- mysql_free_result($hasil);
- // paging
- echo "<tr><td colspan=8 align=center>";
- echo "[ Total Data: $tdata] [ Page $dpage/$tpage ]<b> ";
- for($startp = $dpage - 5; $startp <= $tpage; $startp++) {
- if($startp>0) break;
- }
- if($startp>1) echo "<a href='$href?tdata=$tdata&tpage=$tpage&dpage=1'><<</a> \n";
- $prevp = $dpage-1;
- if($prevp>0) echo "<a href='$href?tdata=$tdata&tpage=$tpage&dpage=$prevp'><</a> \n";
- for($lastp = $startp; $lastp <= $tpage; $lastp++) {
- $angka = $lastp==$dpage ? "<font color=red>$lastp</font>" : "$lastp";
- echo "<a href='$href?tdata=$tdata&tpage=$tpage&dpage=$lastp'>$angka</a> \n";
- if($lastp>=$dpage+5) break;
- }
- $nextp = $dpage+1;
- if($nextp<$tpage) echo " <a href='$href?tdata=$tdata&tpage=$tpage&dpage=$nextp'>></a>\n";
- if($lastp<$tpage) echo " <a href='$href?tdata=$tdata&tpage=$tpage&dpage=$tpage'>>></a>\n";
- echo "</b><br><br><input type='button' value='Print'></td></tr>
- </table>\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment