In this trick we show only three digits if they are on the first page ,the second and last page.eg 123 ... 8.And five-digit paging to another page (two numbers before and after the current page) such as the current page is page 3 , then the pagingnya 12,345 ... 9.So what changed only on the page displaying bagain numbers only.
1.Create table
CREATE TABLE `anggota` (
`id_ang` int(3) NOT NULL auto_increment,
`nama` varchar(50) collate latin1_general_ci NOT NULL,
`alamat` varchar(100) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id_ang`)
2.Script Pagging
$no $data[nama] $data[alamat] "; $no++; } echo "
"; $file="paging_6.php";">paging.php
mysql_connect("localhost","root","root");
mysql_select_db("pintar");
/ / Step 1
$batas=5;
$halaman=$_GET['halaman'];
if(empty($halaman))
{
$posisi=0;
$halaman=1;
}
else
{
$posisi = ($halaman-1) * $batas;
}
//Step 2
$no $data[nama] $data[alamat] "; $no++; } echo "
"; $file="paging_6.php";">$tampil="select * from anggota limit $posisi,$batas";
$hasil=mysql_query($tampil);
$no=$posisi+1;
while ($data=mysql_fetch_array($hasil)){
echo "$no $data[nama] $data[alamat] ";
$no++;
}
echo "
";
$file="paging.php";
//Step 3
$tampil2="select * from anggota";
$hasil2=mysql_query($tampil2);
$jmldata=mysql_num_rows($hasil2);
$jmlhalaman=ceil($jmldata/$batas);
/ / link to the previous page (previous)
1) { $previous=$halaman-1; echo "<<> | <> | "; } else { echo "<<>if($halaman > 1)
{
$previous=$halaman-1;
echo "<<> |
<> | ";
}
else
{
echo "<< First | < Previous | ";
}
/ / display link .. 123 pages google-style modification
/ / initial number
3 ? " ... " : " "); for($i=$halaman-2;$i<$halaman;$i++) { if ($i < href="$file?halaman="$i">$i "; }">$angka=($halaman > 3 ? " ... " : " ");
for($i=$halaman-2;$i<$halaman;$i++)
{
if ($i < 1)
continue;
$angka .= "$i ";
}
1.Create table
CREATE TABLE `anggota` (
`id_ang` int(3) NOT NULL auto_increment,
`nama` varchar(50) collate latin1_general_ci NOT NULL,
`alamat` varchar(100) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id_ang`)
2.Script Pagging
"; $file="paging_6.php";">paging.php
mysql_connect("localhost","root","root");
mysql_select_db("pintar");
/ / Step 1
$batas=5;
$halaman=$_GET['halaman'];
if(empty($halaman))
{
$posisi=0;
$halaman=1;
}
else
{
$posisi = ($halaman-1) * $batas;
}
//Step 2
"; $file="paging_6.php";">$tampil="select * from anggota limit $posisi,$batas";
$hasil=mysql_query($tampil);
$no=$posisi+1;
while ($data=mysql_fetch_array($hasil)){
echo "
$no++;
}
echo "
";
$file="paging.php";
//Step 3
$tampil2="select * from anggota";
$hasil2=mysql_query($tampil2);
$jmldata=mysql_num_rows($hasil2);
$jmlhalaman=ceil($jmldata/$batas);
/ / link to the previous page (previous)
1) { $previous=$halaman-1; echo "<<> | <> | "; } else { echo "<<>if($halaman > 1)
{
$previous=$halaman-1;
echo "<<> |
<> | ";
}
else
{
echo "<< First | < Previous | ";
}
/ / display link .. 123 pages google-style modification
/ / initial number
3 ? " ... " : " "); for($i=$halaman-2;$i<$halaman;$i++) { if ($i < href="$file?halaman="$i">$i "; }">$angka=($halaman > 3 ? " ... " : " ");
for($i=$halaman-2;$i<$halaman;$i++)
{
if ($i < 1)
continue;
$angka .= "$i ";
}
/ / number was
$halaman "; for($i=$halaman+1;$i<($halaman+3);$i++) { if ($i > $jmlhalaman) break; $angka .= "$i "; }">$angka .= " $halaman ";
for($i=$halaman+1;$i<($halaman+3);$i++)
{
if ($i > $jmlhalaman)
break;
$angka .= "$i ";
}
/ / number end
$jmlhalaman " : " ");">$angka .= ($halaman+2<$jmlhalaman ? " ...
$jmlhalaman " : " ");
/ / print all the numbers
echo "$angka";
/ / next view the first link (Next)
Next > | Last >> "; } else { echo " | Next > | Last >>"; } echo "
{
$next=$halaman+1;
echo " | Next > |
Last >> ";
}
else
{
echo " | Next > | Last >>";
}
echo "
?>
$halaman "; for($i=$halaman+1;$i<($halaman+3);$i++) { if ($i > $jmlhalaman) break; $angka .= "$i "; }">$angka .= " $halaman ";
for($i=$halaman+1;$i<($halaman+3);$i++)
{
if ($i > $jmlhalaman)
break;
$angka .= "$i ";
}
/ / number end
$jmlhalaman " : " ");">$angka .= ($halaman+2<$jmlhalaman ? " ...
$jmlhalaman " : " ");
/ / print all the numbers
echo "$angka";
/ / next view the first link (Next)
Next > | Last >> "; } else { echo " | Next > | Last >>"; } echo "
Total anggota : $jmldata orang
"; ?>">if($halaman < $jmlhalaman){
$next=$halaman+1;
echo " | Next > |
Last >> ";
}
else
{
echo " | Next > | Last >>";
}
echo "
Total anggota : $jmldata orang
";?>

0 comments: on "pagging google style"
Post a Comment
Terima kasih atas kunjungan anda