phpcodingfreak Posted May 24, 2013 Share Posted May 24, 2013 <div class="grid_12"> <div class="box first round fullpage mh500 grid"> <h2><?php echo $resource->_pageHead; ?></h2> <?php $resource->displayMessage(); ?> <?php if($resource->_recordCount > 0) { ?> <div class="block"> <table class="listing" > <thead> <tr> <th width="50" class="bdr-left">Sr. No.</th> <th width="60">Name</th> <th width="60">Email</th> <th width="60">Address</th> <th width="60">City</th> <th width="60">State</th> <th width="60">Phone Number</th> <th width="60">Country</th> <th width="60">Comment</th> <th width="60">Inquiry Date</th> <th width="60" class="bdr-right">Action</th> </tr> </thead> <tbody> <?php $i = 1; $_SESSION['number'] = $i; $perpage = 5; $q = mysql_query("SELECT * FROM $resource->_table"); $total_record = mysql_num_rows($q); $pages = ceil($total_record/$perpage); $page = (isset($_GET['page']))?$_GET['page']:1; $start = ($page-1) * $perpage; $result = mysql_query("SELECT * FROM $resource->_table LIMIT $start, $perpage"); while($res = mysql_fetch_array($result)) { ?> <tr class="odd gradeX"> <td><?php echo $i; ?></td> <td><?php echo $res['name']; ?></td> <td><?php echo $res['email'];?></td> <td><?php echo $res['address'];?></td> <td><?php echo $res['city'];?></td> <td><?php echo $res['state'];?></td> <td><?php echo $res['p_code']."-".$res['p_num'];?></td> <td><?php echo $res['country'];?></td> <td><?php echo substr($res['comments'], 0, 100);echo "...";?></td> <td><?php echo $res['inquiry_date'];?></td> <td align="center"> <a href="<?php echo $_SERVER['PHP_SELF'].'?action=delete&id='.$res['id'];?>" onclick="return confirm('Do you want to delete this record?');"> <img src="img/cross.png" alt="Delete" title="Delete"/> </a> </td> </tr> <?php $i++; } } ?> </tbody> </table> </div> <div id="paging" style="padding-left:500px;"> <?php $prev=$page-1; $next=$page+1; if($prev > 0) { echo "<a href='?page=$prev'>Prev</a>"; } echo " "; if($pages >= 1 AND $page <= $pages) { for($x=1;$x<=$pages;$x++) { echo " "; echo ($x==$page) ?"<a href=?page=$x style=\"font-weight:normal;\">$x</a>":'<a href="?page='.$x.'" >'.$x.'</a>'; } echo "  "; if($page<$pages) { echo "<a href='?page=$next'>Next</a>"; } } ?> </div> </div> <div class="clear"></div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/278343-displaying-number-of-records-in-continuous-manner-in-php-paging/ Share on other sites More sharing options...
DavidAM Posted May 24, 2013 Share Posted May 24, 2013 Pretty! ... I give it a 6 - it's indented well, but there aren't any comments and it's not symmetrical. If you want help, you will have to tell us what the problem is or ask a question or something. Quote Link to comment https://forums.phpfreaks.com/topic/278343-displaying-number-of-records-in-continuous-manner-in-php-paging/#findComment-1432025 Share on other sites More sharing options...
phpcodingfreak Posted May 24, 2013 Author Share Posted May 24, 2013 @DavidAM:- I asked question but don't know why it not displaying it. Well the question is: I have a page which displays number of records on each page. I am displaying 5 records on each page and then next 5 on the next page and so on. Paging is working fine but the problem is on first page I'm displaying number serial wise next to each record i.e. from 1 to 5. Then on next page it should display numbers from 6 to 10 and on next page 11 to 15 and so on. But on every page numbers start from 1 to 5. My code is below. I have tried different strategies but nothing worked. Please check code and tell me where to make changes so that it works properly. Thanks a ton in advance. Quote Link to comment https://forums.phpfreaks.com/topic/278343-displaying-number-of-records-in-continuous-manner-in-php-paging/#findComment-1432037 Share on other sites More sharing options...
mac_gyver Posted May 24, 2013 Share Posted May 24, 2013 you are setting $i = 1; use the following (after the point where you calculate $start) - $i = $start + 1; Quote Link to comment https://forums.phpfreaks.com/topic/278343-displaying-number-of-records-in-continuous-manner-in-php-paging/#findComment-1432044 Share on other sites More sharing options...
phpcodingfreak Posted May 24, 2013 Author Share Posted May 24, 2013 @mac_gyver:- Thanks a gazillion ton. I was working on this from the whole day today but with no result. Didn't know it was so simple. You have soled a big issue for me. Thanks lot again. Quote Link to comment https://forums.phpfreaks.com/topic/278343-displaying-number-of-records-in-continuous-manner-in-php-paging/#findComment-1432046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.