kafia Posted December 15, 2009 Report Share Posted December 15, 2009 hi every one if any one can help me with the code for pagination spose if i have 20 record from a mysql table how i can print that record on a page line wise and column wise for example if like the print 5 record in a row and 4 rows on page how it is please help me with a simple code example best regard Link to comment Share on other sites More sharing options...
justsomeguy Posted December 15, 2009 Report Share Posted December 15, 2009 Do a search for pagination with PHP, there are a lot of examples about it. Link to comment Share on other sites More sharing options...
Redroest Posted December 15, 2009 Report Share Posted December 15, 2009 first of all, you have to ouput the first 20 records. Then do the following: <?php //Set number of columns per <tr> $ColsPerRow = 5; echo "<table align='center'>"; echo " <tr>"; $i=0; //Loop trough the result of your query. In my case this is a photoalbum for a albumlist while($AlbumTree = $db->sql_fetchrow($AlbumQuery)) { //if the last column is set, ouput <tr> if($i == $ColsPerRow) { echo "<tr>"; } else { $i++; } echo " <td align='center' width='130'><a href='modules.php?name=photoalbum&album=".$AlbumTree["AlbumID"]."'><input type='image' src='".$AlbumTree["AlbumThumb"]."'><br /><strong>".$AlbumTree["AlbumCustomName"]."</strong></a></td>"; if($i == $ColsPerRow) { //after the last column set </tr> echo "</tr>"; $i=0; } }?> I don't have any examples for pagination but justsomeguy helped you with that Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now