Jump to content

Moving page numbers pagination


iNko

Recommended Posts

Hi, somehow iv managed to add pagination to my project, but im struggling with one thing - i dont know how to move the pagination "symbols" (idk how they r called)..

here's a pic that will explain what im talking about:

25fpt0z.png

 

and heres the code that im using:

//The directory to your images folder, with trailing slash
$dir = "uploads/thumbs/watermarkedthumbs/";
//Set the extensions you want to load, seperate by a comma.
$extensions = "jpeg,jpg";
//Set the number of images you want to display per page
$imagesPerPage = 4;
//Set the $page variable
if(!isset($_GET['page'])){
$page = 1;
}else{
$page = $_GET['page'];
}
//Load all images into an array
$images = glob($dir."*.{".$extensions."}", GLOB_BRACE);
//Count the number of images
$totalImages = count($images);
//Get the total pages
$totalPages = ceil($totalImages / $imagesPerPage);
//Make sure the page you are on is not greater then the total pages available.
if($page > $totalPages){
//Set the currnet page to the total pages.
$page = $totalPages;
}
//Now find where to start the loading from
$from = ($page * $imagesPerPage) - $imagesPerPage;
//Now start looping
for($i = $from; $i < ($from + $imagesPerPage); $i++){
//We need to make sure that its within the range of totalImages.
if($i < $totalImages){
	//Now we can display the image!
 	  echo "<img style='border:thin solid #FFF;margin-top:10px;margin-left:10px;margin-right:10px' src='{$images[$i]}'alt='{$images[$i]}' />";		
}
}

//Now to display the page numbers!
for($p = 1; $p <= $totalPages; $p++){
if($p == $page){
	$tmp_pages[] = "<strong>{$p}</strong>";
}else{
	$tmp_pages[] = "<a href='?page={$p}'>{$p}</a>";
}
}

//Now display pages, seperated by a hyphon.
echo "<br />" . implode(" - ", $tmp_pages);
?>

 

how do i move the 'page numbers' ?

thx in advance

Link to comment
https://forums.phpfreaks.com/topic/260968-moving-page-numbers-pagination/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.