PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 9th, 2013, 11:47 AM
josephbupe josephbupe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 56 josephbupe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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&param2=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$sql164null );

//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 >= ){
    
//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>&nbsp; \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

Reply With Quote
  #2  
Old February 9th, 2013, 01:05 PM
simplypixie simplypixie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 104 simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level)simplypixie User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 18 h 33 m 57 sec
Reputation Power: 11
You have nothing in your while loop to count how many images have been displayed so far and then create a new row if on the 4th image, hence why you are just getting one long row of 16 images.

Below is what you need to do but I have separated the PHP and HTML as I just can't work efficiently with code the way you have it and it is much easier to change and debug when separated.

PHP Code:
if($num >= ) { 
    
//creating our table header 
?>
<table>
<tr>
<?php
    
//looping through the records retrieved 
    
$count 0;
    while( 
$row $rs->fetch_assoc() ){ ?>

   <td valign=top>
     
    <table width=150 border=1 align=left class=allborder> 
    <tr> 
    <td width=70><?php echo $row[ctitle]; ?></td>
    </tr>
     
    <tr> 
        <td><img src="./images/<?php echo $row['cfilename']; ?>" width="90" height="120" alt="" /></a>
        </td> 
    </tr> 
         
    </table>
</td>
<?php $count++; 
  if (
$count %== && $count $num) {
?>
</tr><tr>
<?php 
}  
?>
</tr>
</table> 
<?php ?> 
Comments on this post
josephbupe agrees: It work ! Thank youso much. Stay well.

Reply With Quote
  #3  
Old February 9th, 2013, 03:27 PM
josephbupe josephbupe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 56 josephbupe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 10 m 2 sec
Reputation Power: 1
Hi simplypixie,

Your solution worked a charm. Thank you so much.

Stay well.

joseph

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Paginating Your Data with AJAX and Awesome PHP Pagination Class

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap