Selasa, 02 Desember 2014

Kode Untuk Membuat Paging #plus plus

Sebelum lanjut ke materi, kita haru ngerti dulu seperti apa sebenernya yang disebut-sebut sebagai "paging" itu. Paging merupakan sebuah teknik untuk menampilkan data yang sangat banyak. Nggak mungkin kan kita menampilkan data yang jumlahnya ribuan dalam sekali klik saja. Oleh sebab  itu teknik paging sangat berguna untuk lebih mempermudah kita.

salah satu contoh bentuk paging :




 berikut adalah kodenya :

     require_once('../include/fungsi.php');    //kode fungsi.php bisa anda lihat di bagian bawah
?>





# Admin | Data Pelanggan #





    
:: DATA PELANGGAN  DEALER MOTORKITA::

    
       
         
         
         
         
         
       
       //kode membuat paging
                    $hal = $_GET[hal];
            if(!isset($_GET['hal'])){
                    $page = 1;
            } else {
                 $page = $_GET['hal'];
            }
            $jmlperhalaman =5;  // jumlah record per halaman
            $offset = (($page * $jmlperhalaman) - $jmlperhalaman);

            $total_record = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM pelanggan"),0);
          
            $rs1=mysql_query("select * from pelanggan order by kode_cust limit $offset, $jmlperhalaman");
          
            while($query=mysql_fetch_row($rs1)){
        ?>
       
         
         
         
         
         
       
      
        
       
KODE PELANGGAN
NAMA
DETAIL PELANGGAN
EDIT PELANGGAN
DELETE PELANGGAN
DetailEditDelete



     PagingRecords($hal,$total_record,$jmlperhalaman,$page);
?>
    
Tambah





Kode fungsi.php

function PagingRecords($hal,$total_record,$jmlperhalaman,$page)
    {
        // membuat nomor halaman
$total_halaman = ceil($total_record / $jmlperhalaman);
echo "
Halaman :
";
$perhal=4;
if($hal > 1){
    $prev = ($page - 1);
    echo " << ";
}
if($total_halaman<=10){
$hal1=1;
$hal2=$total_halaman;
}else{
$hal1=$hal-$perhal;
$hal2=$hal+$perhal;
}
if($hal<=5){
$hal1=1;
}
if($hal<$total_halaman){
$hal2=$hal+$perhal;
}else{
$hal2=$hal;
}
for($i = $hal1; $i <= $hal2; $i++){
    if(($hal) == $i){
        echo "[$i] ";
        } else {
    if($i<=$total_halaman){
            echo "$i ";
    }
    }
}
if($hal < $total_halaman){
    $next = ($page + 1);
    echo ">>";
}
echo "
";
}
?>



 Hasil tampilan :











*semoga bermanfaat. ^_^

1 komentar:

  1. Did you realize there is a 12 word sentence you can speak to your crush... that will trigger deep emotions of love and impulsive appeal for you buried within his chest?

    That's because deep inside these 12 words is a "secret signal" that fuels a man's impulse to love, adore and guard you with all his heart...

    ====> 12 Words That Trigger A Man's Desire Impulse

    This impulse is so built-in to a man's genetics that it will make him work harder than before to make your relationship as strong as it can be.

    Matter of fact, fueling this influential impulse is so essential to getting the best ever relationship with your man that the instance you send your man one of these "Secret Signals"...

    ...You'll soon notice him open his soul and heart for you in such a way he haven't experienced before and he'll distinguish you as the one and only woman in the world who has ever truly interested him.

    BalasHapus