
February 9th, 2013, 11:47 AM
|
|
Contributing User
|
|
Join Date: Nov 2012
Posts: 56
Time spent in forums: 13 h 10 m 2 sec
Reputation Power: 1
|
|
|
PHP-General - Paginating Your Data with AJAX and Awesome PHP Pagination Class
Hi,
I am trying to implement a pagination script called Paginating Your Data with AJAX and Awesome PHP Pagination Class for navigating through a gallery of images but when I set more than eight records per page the images appear to go beyond the browser horizontally in a single infinity row instead of starting a new row below the first row.
I want the number of records (images) per page to be 16 arranged in two rows(eight images in the upper row and 8 images in the bottom row).
Please, help. Here is my code:
PHP Code:
<?php
//query all data anyway you want
$sql = "select * from collections ORDER BY c_id ASC";
//now, where gonna use our pagination class
//this is a significant part of our pagination
//i will explain the PS_Pagination parameters
//$conn is a variable from our config_open_db.php
//$sql is our sql statement above
//8 is the number of records retrieved per page
//4 is the number of page numbers rendered below
//null - i used null since in dont have any other
//parameters to pass (i.e. param1=valu1¶m2=value2)
//you can use this if you're gonna use this class for search
//results since you will have to pass search keywords
$pager = new PS_Pagination( $mysqli, $sql, 16, 4, null );
//our pagination class will render new
//recordset (search results now are limited
//for pagination)
$rs = $pager->paginate();
//get retrieved rows to check if
//there are retrieved data
$num = $rs->num_rows;
if($num >= 1 ){
//creating our table header
//looping through the records retrieved
while( $row = $rs->fetch_assoc() ){
echo "<td valign=top>\n
<table width=150 border=1 align=left class=allborder> \n
<tr> \n
<td width=70>$row[ctitle]</td> \n
</tr>\n
<tr> \n
<td><img src=\"./images/{$row['cfilename']}\" width=\"90\" height=\"120\" alt=\"\" /></a> \n
</td>
</tr>\n
</table>\n</td>\n
";
}
{
echo "</tr>\n<tr>\n<td colspn=2> \n";
}
echo "</table>";
}
else{
//if no records found
echo "No records found!";
}
?>
I did not have this problem with other mysql pagination codes I used before. It's now that I have re-written my code in mysqli and i need this pagination.
Joseph
|