Pagging sederhana dengan php ( Pagging simple php )

what the heck it pagging
pagging is a technique mempage web pages with navigation so easy to use,,,for example: if our school has an alumni of some of data totaling 1000 more, it may not show all of us, can-can display a web page we can roll the existing scrollbar on the left,,, also make the user feel bored because most look to the page .. bwah
for that we need to do pagging techniques.
okay this time I encourage pagingnya technique directly with the database,,,if static Ntar not know yet so complicated swaktu memakaai database ...
1. First we have to do is create a database.create a database with names IHT
2. Create a table named dataalumniHis requirements:
no (int) 11name (varchar) 255tahunlulus (varchar) 255primary key (no) auto_increment
3. The contents of its alumni data:content is up to you an important number, name, n tahunlulus filled
4. Create a connection to the database file.

koneksi.php

PHP Code:$ Host = "localhost";$ User = "root";$ Pass = "";$ Db = "page";mysql_connect ($ host, $ user, $ pass);mysql_select_db ($ db);?>
5. After that we create a file paggingnya
pagging.php
PHP Code:include "koneksi.php";
$ Table = dataalumni;
$ Terms = $ _GET ['case']; / / load variables get
if (! isset ($ _GET ['case'])){$ Page = 1;}
else {$ Page = $ _GET ['case'];}
$ Max_results = 6; / / total display or data mempage
$ From = (($ page * $ max_results) - $ max_results); / / script for the start of the page
echo "





";
$ Show = mysql_query ("SELECT * FROM $ table ORDER BY name DESC LIMIT $ from, $ max_results");$ Number = 1;while ($ r = mysql_fetch_array ($ show)) {echo "




";$ No;}
echo "No.Alumni Name
Year Graduated$ No$ R [name] $ r [tahunlulus]";?>
Pages:
$ Total_results = mysql_result (mysql_query ("SELECT COUNT (*) as Num FROM $ table"), 0);$ Total_pages = ceil ($ total_results / $ max_results);
if ($ case> 1) {$ Prev = ($ page - 1);echo "$ prev";}
for ($ i = 1; $ i <= $ total_pages; $ i) {
if (($ this) == $ i) {echo "$ i";}else{echo "$ i";}}/ / Build Next Linkif ($ this <$ total_pages) {$ Next = ($ page 1);echo "$ next";}?>



credit : forum kita bersama

0 komentar pada Pagging sederhana dengan php ( Pagging simple php )

Posting Komentar

 
Copyright © 2010 - Subma Ompol's CSS3 | Design by subma