kpraman Posted March 14, 2007 Share Posted March 14, 2007 Hello i want to display multiple paging in the same page and if i click the hyperlinks of (next,previous etc), only the values of that table should change. can any one give me some idea of doing it? Is there any example in anyother site for displaying multiple paging? example: ORDERSET ID-1 orders <first><next><preivious><last> ORDERSET ID-2 orders <first><next><preivious><last> " " ...ORDERSET ID-n Link to comment https://forums.phpfreaks.com/topic/42629-multple-paging/ Share on other sites More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 In the 'next page' URL set it to: <a href="this_page.php?page=2"> Then use the: $_GET['page'] value as an offset, so say we have ten items per page: $items = 10; $start_item = $items * intval( $_GET['page'] ); Now load the data, starting at position $start_item, and showing $items rows of data. Now the next link will look like: <a href="this_page.php?page='. ( intval( $_GET['page'] ) + 1 ) .'"> I hope this gives you enough info to try some more code. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42629-multple-paging/#findComment-206889 Share on other sites More sharing options...
kpraman Posted March 14, 2007 Author Share Posted March 14, 2007 This is the code wrote and tried, i am able to display but when i click on the links all the values gets changed. <?php $querytop=mysql_query("SELECT * FROM picture_set"); while($r=mysql_fetch_array($querytop)) { $picture_setId=$r['picture_Set_Id']; $list.="<table border=1 align='center'> <tr><td>$r[picture_Set_Name]</td></tr></table>"; $minlimit=$_GET['minlimit']; if(empty($minlimit)) $minlimit=0; $row=2; $col=1; $limit=$row*$col; $i=0; $query="SELECT * FROM pictures WHERE picture_setId=$picture_setId"; $query_res=mysql_query($query); $tot=mysql_num_rows($query_res); $sql="SELECT * FROM pictures WHERE picture_setId=$picture_setId LIMIT ".$minlimit.",".$limit; $sql_res=mysql_query($sql); if(mysql_num_rows($sql_res) > 0) { $list.="<table border=1 align='center'>"; while($sql_ret=mysql_fetch_array($sql_res)) { $i++; $picture_Id=$sql_ret['picture_Id']; if($i%6==1) $list.="<tr>"; $list.="<td>$picture_Id</td>"; if($i%6==0) $list.="</tr>"; $link=getLinks($tot,$minlimit,$limit,$_SERVER[php_SELF]."?&picture_setId=$picture_setId&"); } $list.="<tr><td colspan='5'>$link[0]</td></tr></table>"; $minlimit=$_GET['minlimit']; if(empty($minlimit)) $minlimit=0; $row=2; $col=1; $limit=$row*$col; $i=0; $query="SELECT * FROM pictures WHERE picture_setId=$picture_setId"; $query_res=mysql_query($query); $tot=mysql_num_rows($query_res); $sql="SELECT * FROM pictures WHERE picture_setId=$picture_setId LIMIT ".$minlimit.",".$limit; $sql_res=mysql_query($sql); if(mysql_num_rows($sql_res) > 0) { $list.="<table border=1 align='center'>"; while($sql_ret=mysql_fetch_array($sql_res)) { $i++; $picture_Id=$sql_ret['picture_Id']; if($i%6==1) $list.="<tr>"; $list.="<td>$picture_Id</td>"; if($i%6==0) $list.="</tr>"; $link=getLinks($tot,$minlimit,$limit,$_SERVER[php_SELF]."?&picture_setId=$picture_setId&"); } $list.="<tr><td colspan='5'>$link[0]</td></tr></table>"; } } } ?> Paging function function getLinks($total,$minlimit,$limit,$file,$mstring="") { $limitto=""; if($mstring=="") $mstring="minlimit"; if($total>$limit) { if($minlimit!=0) $firstpglink="<a href='".$file."$mstring=0&limit=$limit' class='pglink'>First</a>"; else $firstpglink="<span class='contentblackbold'>First</span>"; if($limit != 0 && $total != 0) { if($total%$limit) { $lastcc=floor($total/$limit)*$limit; } else { $lastcc=(($total/$limit)-1)*$limit; } if($minlimit < $lastcc) $lastpglink="<a href='".$file."$mstring=$lastcc&limit=$limit' class='pglink'>Last</a>"; else $lastpglink="<span class='pglink'>Last</span>"; } if($minlimit>=$limit) { $prevcc=$minlimit-$limit; $prevpglink="<a href='".$file."$mstring=$prevcc&limit=$limit' class='pglink'>Prev</a>"; } else $prevpglink="<span class='pglink'>Prev</span>"; if($minlimit < (($total/$limit)-1)*$limit) { $nextcc=$minlimit+$limit; $nextpglink="<a href='".$file."$mstring=$nextcc&limit=$limit' class='pglink'>Next</a>"; } else $nextpglink="<span class='pglink'>Next</span>"; if(($minlimit+$limit)>$total) $limitto=$total; else $limitto=$minlimit+$limit; $links[0]="<span class='pglink'>[ ".$firstpglink." | ".$prevpglink." | ".$nextpglink." | ".$lastpglink." ]<span>"; } else $links[0]=""; $links[1]="Showing ".($minlimit+1)."-".$limitto." of ".$total; return $links; } Link to comment https://forums.phpfreaks.com/topic/42629-multple-paging/#findComment-206906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.