PHP Simplicity Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

I am not always around so I might be late on replying.

Author Topic: Pagination tutorial  (Read 1094 times)

0 Members and 1 Guest are viewing this topic.

John Merlino

  • Guest
Pagination tutorial
« on: October 27, 2010, 11:49:09 PM »

I have a page of images which are showing in a main template window.  I need to add pagination to them as their is over 900 images.  I have this working but it is not paginating although it is showing in the URL.  I have set a session should I have used that instead of the url.  It is showing the two links although I still need to format them with images and as I mentioned it is showing the number increases and decreases by 32 in the browser address but the images are not changing?  Any consideration and assistance would be greatly appreciated.

Here is my code.
Code: [Select]
<?PHP session_start();
include 'php-bin/dbConn.php';

//Count Number of Rows
$sql_get_gallery_photo_info = ("SELECT * FROM AL_gallery_images ORDER BY uploadDate DESC LIMIT $startrow 32");
$result = mysql_query($sql_get_gallery_photo_info) or die('Could not query:' . mysql_error());

//Begin pagination check if the starting row variable was passed in the URL or not
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
  //we give the value of the starting row to 0 because nothing was found in URL
  $startrow = 0;
//otherwise we take the value from the URL
} else {
  $startrow = (int)$_GET['startrow'];
}

//this part goes after the checking of the $_GET var
//$sql_get_gallery_photo_info = mysql_query("SELECT * FROM AL_gallery_images LIMIT $startrow, 32") or die(mysql_error());

while ($rows = mysql_fetch_array($result)) {
$records[] = array(1 => $rows['imageName']);
$userIDs[] = array(1 => $rows['userID']);
}
?>
Logged
 

+ Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.
Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What is the answer to one plus one? (in numbers):