Pagination - help please!

Hi everyone!

I’m making my own website and im posting ‘pictures’ (they are actualy screenshots of other web pages). When i add new ‘pictures’, the other ones have to go to the next page. Its called ‘pagination’.

Im browsing the web for pagination for days now. But the only tutorials I find are names in records (via phpMyadmin) and when a person presses page 2, other names appear.

example:http://imageshack.us/photo/my-images/33/voorbeeldj.jpg/

As you can see i got like 8 pictures, when i press “page 2” the next 8 pictures should appear. But when i want to add some other pictures next week, the ones that are on page 1 now should move to page 2, if you know what i mean.

PLEASE HELP ME, if been searching on forums (in my native language), but I cant find solutions. Im really desperate :s.

So im searching:
A good pagination tutorial, that not only shows how to build the pagination itself but also show how to add pictures, wich on their turn move the other pictures to another page.

Thanks in advance!

Hi,

I use this for my pagination.

[php]
$max = 10; // SET THIS TO THE NUMBER OF RESULTS PER PAGE

if(!isset($_GET[‘page’])){$page = 1;}else{$page = (int)$_GET[‘page’];}
$start = ($page -1) * $max;
$q = mysql_query(“PUT YOUR QUERY IN HERE”);
$res1 = mysql_num_rows($q);
$pages = ceil($res1 / $max);// divide the amount of reults by the max amount of reults allowed and then round up using ceil

// query to get the results ready to output
// make sure you leave the start and max in the query below
$query1 = mysql_query(“PUT YOUR QUERY HERE LIMIT $start , $max”);
$result = mysql_num_rows($query1);

// this displays the next and previous pagnation links
if($page != 1 ) { $previous = $page -1; echo 'Previous '. " ";}

		// this displays the page numbers	
		echo 'Page '.$page.'  of  '.$pages.'';
		// show the next button if the user isnt on the last page
		if($page != $pages) { $next = $page +1; echo '<a href="?page='.$next.'"> Next</a>'. " ";}

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service