augustin1340
augustin1340

Reputation: 47

Pagination : First, Next, Previous, Last

I want to create a pagination system. I don't know how create the first page and last page ??? I have arrived for the page "previous" and "next".

first | << previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | next >> | last

Here is my code:

if($pageCourante!=1)
{
    $precedant = $pageCourante-1; 
    echo'<a href="index.php?page='.$precedant.'">«Precedant»</a>'; 

}


for($i=1; $i<=$pageTotal; $i++) 
{
  echo'<a href="index.php?page='.$i.'">'.$i.'</a>';       
}

if($pageCourante<$pageTotal){
    $suivant= $pageCourante+1;
    echo'<a href="index.php?page='.$suivant.'">«Suivant»</a>';   
}

Upvotes: 0

Views: 482

Answers (1)

kchason
kchason

Reputation: 2885

Assuming page 1 is the first page:

echo '<a href="index.php?page=1">First</a>';

And assuming $pageTotal is the last page ID:

echo '<a href="index.php?page='.$pageTotal.'">Last</a>';

Upvotes: 1

Related Questions