Jump to content

adding pagination to a random display of data


barrowvian

Recommended Posts

Currently I have this;

					<?php 
					// orders and displays the results randomly in rows of 16.
					$_num = 0;
					$result = mysql_query("SELECT image_link FROM adverts ORDER BY RAND()",$connection);

					while($row = mysql_fetch_array($result)){
						echo $row['image_link'] . " ";
						$_num++;

						if ($_num == 16){
								echo "<br />";
  								$_num = 0;
							}
					}			
				?>

 

It simply queries my database at returns the results in a random order.

 

Now what I am wanting to do is add pagination but still keep the display random. How would I go about doing this? I have been looking through the pagination tutorial here on php freaks and have the pagination working on its own, but now I am wanting to combine the two but have no idea what to do :)

 

Here's a fairly simple pagination class file that I use all the time. It's simple, but it still gives you a page list, next page, previous page, etc., all from just an array, per page number, and current page number.

 

[attachment deleted by admin]

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.