Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,179 members, 7,821,986 topics. Date: Wednesday, 08 May 2024 at 11:44 PM

Perfect Pagination Like NAIRALAND - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Perfect Pagination Like NAIRALAND (626 Views)

How To Add Numbered Pagination To A Blogger Blog / How To Create A Site Like Nairaland•com And Make Your Money / Design A Website Like Nairaland For N150,000 (2) (3) (4)

(1) (Reply) (Go Down)

Perfect Pagination Like NAIRALAND by KOLONIZA: 3:16pm On Jun 07, 2013

this site is one of the great site in Nigeria, i realy love bin arond ere, the little problem i had down ere is dat did anyone has a nice pagination in php like dat on NAIRALAND or maybe Nloaded or sofin related to dat like this format

[1] [2] [3] [4] [5] [6] [7] [8] [10] [last]
Re: Perfect Pagination Like NAIRALAND by spikesC(m): 3:23pm On Jun 07, 2013
You can easily do that yourself
Re: Perfect Pagination Like NAIRALAND by miracle4(m): 3:25pm On Jun 07, 2013
are you looking for free solution or paying for it, besides which site are you trying to implement it ?
Re: Perfect Pagination Like NAIRALAND by shorxynla(m): 9:30pm On Jun 07, 2013
I can do that for you. Check here www.crownitesforum.com
Re: Perfect Pagination Like NAIRALAND by Nobody: 9:33pm On Jun 07, 2013
I did something like that few weeks ago.. Not as perfect though, but its worth it.

   $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$page_start = ($page - 1) * 10;


function NLPagination($total_pages,$page,$limit,$targetpage){

//Pager
$stages = 3;
// Initial page num setup
if ($page == 0){$page = 1;}
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);


$paginate = '';
if($lastpage > 1)
{


//First
if ($page != 1 && $page > 7) {
$paginate.= "<a href='".$targetpage."page=1' class='link'>(First)</a>&nbsp;";
}else{
$paginate.= ""; }

// Previous
if ($page > 6){
$paginate.= "<a href='".$targetpage."page=$prev' class='link'>(Previous)</a>&nbsp;";
}else{
$paginate.= ""; }



// Pages
if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "($counter)";
}else{
$paginate.= "<a href='".$targetpage."page=$counter' class='link'>($counter)</a>&nbsp;";}
}
}
elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few?
{
// Beginning only hide later pages
if($page < 1 + ($stages * 2))
{
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
{
if ($counter == $page){
$paginate.= "($counter)";
}else{
$paginate.= "<a href='".$targetpage."page=$counter' class='link'>($counter)</a>&nbsp;";}
}
}
// Middle hide some front and some back
elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
{
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
{
if ($counter == $page){
$paginate.= "($counter)";
}else{
$paginate.= "<a href='".$targetpage."page=$counter' class='link'>($counter)</a>&nbsp;";}
}
}
// End only hide early pages
else
{
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page){
$paginate.= "($counter)";
}else{
$paginate.= "<a href='".$targetpage."page=$counter' class='link'>($counter)</a>&nbsp;";}
}
}
}

// Next
if ($page < $counter - 1 && $page > 7){
$paginate.= "<a href='".$targetpage."page=$next' class='link'>(Next)</a>&nbsp;";
}else{
$paginate.= "";
}

//Last
if ($page > 7 && $page != $lastpage) {
$paginate.= "<a href='".$targetpage."page=$lastpage' class='link'>(Last)</a>&nbsp;";
}else{
$paginate.= ""; }
//NumLast

if($page && $page !== 1 && $page !== $lastpage){
$paginate.=" (Of $lastpage Pages)";
}

}else{
$paginate ="";
}
//End Pager
$pages = $paginate;

return $pages;
// echo $paginate;
}

//To Call
$limit = 10; //Number of Rows
$query = mysql_query("SELECT * FROM table WHERE dis='$dat' ORDER BY id DESC LIMIT $page_start,$limit"wink;

$total = mysql_num_rows(mysql_query("SELECT * FROM table WHERE dis='$dat'"wink)

$targetpage = "/forum/index.php?";
//To Call Function
$my_nl_page = NLPagination($total,$page,$limit,$targetpage);

//To display pager
echo "<p>".$my_nl_page."</p>";
Re: Perfect Pagination Like NAIRALAND by KOLONIZA: 2:03pm On Jun 09, 2013
Thats prety gud buh u guy can give dis out widout requestin 4a any tin, actually i want to implement it to www.naijakey.com buh avnt hosted d site dt pagination was ma lil prob, d ones i had was juz 4 pages ahead
Re: Perfect Pagination Like NAIRALAND by Nobody: 2:52pm On Jun 09, 2013
^^ Didn't really get you. But, if you're looking for something like Nairaland, then that works!

Re: Perfect Pagination Like NAIRALAND by spikesC(m): 8:33pm On Jun 09, 2013
KOLONIZA: Thats prety gud buh u guy can give dis out widout requestin 4a any tin, actually i want to implement it to www.naijakey.com buh avnt hosted d site dt pagination was ma lil prob, d ones i had was juz 4 pages ahead

The way you ask a question determines the reply you get. Developers here help each other free but still keeps it professional when need be, we still need jobs, right?
Re: Perfect Pagination Like NAIRALAND by KOLONIZA: 4:31pm On Jun 10, 2013

thanks to you guys, ure a life saver.
Re: Perfect Pagination Like NAIRALAND by KOLONIZA: 4:32pm On Jun 10, 2013
Judinho59: ^^ Didn't really get you. But, if you're looking for something like Nairaland, then that works!

thanks bro

(1) (Reply)

I Present 2 of My Websites for reviews / See What Saw In My Inbox Today. / Pls Guys Check Out My New Website

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.