Pages help...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SMOK3
    replied
    Originally posted by ionutvmi View Post
    PHP Code:
    <?
    // wap-landz.tk
    function pagination($total,$current,$perpage='10',$url=''){
    if($total >= $perpage){
    $totalpages=round($total/$perpage);
    $totalpages2=$total/$perpage;
    if($totalpages2>$totalpages)
    $totalpages=$totalpages+1;
    $pagesar['First'] = "1";
    if($current > 1){
    $cd=$current-1;
    $pagesar['Prev'] = $cd;
    if($cd==1)
    $st=1;
    else if($cd==2)
    $st=$cd-1;
    else if($cd>=3)
    $st=$cd-2;
    for($i=$st;$i<=$cd;$i++){
    $pagesar[$i] = $i;
    }
    }
    if($totalpages > $current+4)
    $finalstop=$current+4;
    else
    $finalstop=$totalpages;
    for($j=$current;$j<=$finalstop;$j++){
    $pagesar[$j] = $j;
    }
    if($totalpages > $current)
    $pagesar['Next'] = $current+1;
    $pagesar['Last'] = $totalpages;
    }else{
    $pagesar['1'] = "1";
    }
    if(is_array($pagesar))
    {
    print "Pages:&nbsp;&nbsp;";
    foreach($pagesar as $key => $val)
    {
    if($val == $current)
    { print $key."&nbsp;&nbsp;"; }
    else{ print "<a href=\"".$url."?page=$val\">".$key."</a>&nbsp;&nbsp;"; }
    }
    }
    }
    // how to use
    $c=$_GET['page'];
    if (!$c) $c=1;
    pagination(24,$c,5);
    ?>
    how do i make this work with session id?

    Leave a comment:


  • wap_king
    replied
    Originally posted by hidden
    juz copy it from any toplist sccript
    dont have any thanx ori and ionutvmi...i made the code here it is i use a function

    function pages($num_pages, $page, $link )
    {
    if($num_pages > 1)
    {
    if($page > 1 )
    {
    $ppage = $page-1;
    echo '<a href="'.$link.'&amp;page='.$ppage.'">&#171;</a>';
    echo ' | ';
    }else{
    echo '&#171;';
    echo ' | ';
    }
    for ($i = 1; $i <= $num_pages; $i++)
    {
    if($page == $i)
    {
    echo '<b>'.$i.'</b>';
    echo ' | ';
    }else{
    echo '<a href="'.$link.'&amp;page='.$i.'">'.$i.'</a>';
    echo ' | ';
    }}
    if(($page < $num_pages) && ($num_pages > 1))
    {
    $npage = $page+1;
    echo '<a href="'.$link.'&amp;page='.$npage.'">&#187;</a>';
    }else{
    echo '&#187;';
    }
    }
    }

    Leave a comment:


  • ionutvmi
    replied
    PHP Code:
    <?
    // wap-landz.tk
    function pagination($total,$current,$perpage='10',$url=''){
    if($total >= $perpage){
    $totalpages=round($total/$perpage);
    $totalpages2=$total/$perpage;
    if($totalpages2>$totalpages)
    $totalpages=$totalpages+1;
    $pagesar['First'] = "1";
    if($current > 1){
    $cd=$current-1;
    $pagesar['Prev'] = $cd;
    if($cd==1)
    $st=1;
    else if($cd==2)
    $st=$cd-1;
    else if($cd>=3)
    $st=$cd-2;
    for($i=$st;$i<=$cd;$i++){
    $pagesar[$i] = $i;
    }
    }
    if($totalpages > $current+4)
    $finalstop=$current+4;
    else
    $finalstop=$totalpages;
    for($j=$current;$j<=$finalstop;$j++){
    $pagesar[$j] = $j;
    }
    if($totalpages > $current)
    $pagesar['Next'] = $current+1;
    $pagesar['Last'] = $totalpages;
    }else{
    $pagesar['1'] = "1";
    }
    if(is_array($pagesar))
    {
    print "Pages:&nbsp;&nbsp;";
    foreach($pagesar as $key => $val)
    {
    if($val == $current)
    { print $key."&nbsp;&nbsp;"; }
    else{ print "<a href=\"".$url."?page=$val\">".$key."</a>&nbsp;&nbsp;"; }
    }
    }
    }
    // how to use
    $c=$_GET['page'];
    if (!$c) $c=1;
    pagination(24,$c,5);
    ?>

    Leave a comment:


  • ori
    replied
    this might be bit complicated but shows 4 page number before and after current page but only if they exist

    PHP Code:
    $num_pages = ceil($smileys/$imagesperpage);
    if (
    $_GET['page'] - 4 < 1) $pagemin = 1;
    else 
    $pagemin = $_GET['page'] - 4;
    $maxPage = $num_pages;
    if (
    $_GET['page'] + 4 > $maxPage) $pagemax = $maxPage;
    else 
    $pagemax = $_GET['page'] + 4;
    if (
    $_GET['page'] > 1) $controls .= "<a href=\"".$action."extras".$mod."smileys&amp;page=".($_GET['page']-1)."\">Prev</a>\n";
    else 
    $controls .= "Prev\n";
    for(
    $page = $pagemin; $page <= $pagemax; $page++) 
    {
    if (
    $page == $_GET['page']) $controls .= " $page \n";
    else 
    $controls .= " <a href=\"".$action."extras".$mod."smileys&amp;page=$page\">$page</a> \n";
    }
    if (
    $_GET['page'] < $num_pages) $controls .= "<a href=\"".$action."extras".$mod."smileys&amp;page=".($_GET['page']+1)."\">Next</a>";
    else 
    $controls .= "Next";
    if (
    $page > 1 || $smileys > ($page*$imagesperpage)) $controls .= "<br/>"; 

    Leave a comment:


  • wap_king
    replied
    can any one help me a example of whati want is right here on the right at the bottom where Page 1 of 2 [1][2][>][Last>>] thats how i want it

    Leave a comment:


  • wap_king
    replied
    thanx bro hope it helps me thanx again...

    Leave a comment:


  • Anshul
    replied
    check this it wil help u i am uploading pager files and its examples
    Attached Files

    Leave a comment:


  • wap_king
    replied
    oh yeah i get it did u see my last post about the code?

    Leave a comment:


  • something else
    replied
    $i is just a varible it could be anything eg:
    for ($something_else = $ppage; $something_else <= ($page+5); $something_else++) {

    Leave a comment:


  • wap_king
    replied
    yeah this seems to work....thanx...but the problem now is that when am on the last page for example page 4 is the last page it shows this Prev [-1][0][1][2][3][4][5][6][7][8][9] Next
    Last edited by wap_king; 20.07.10, 17:40.

    Leave a comment:


  • something else
    replied
    try
    PHP Code:
    if($page>1){  
    $ppage = $page-1;  
    echo 
    "<a href=\"index.php?page=$ppage\">«Prev</a> ";  
    }  
    $capped_pages = $total_pages-4; 
    if(
    $page==1){  
    for (
    $i = $page; $i <= ($page+5); $i++) {   
    if(
    $i<=$total_pages){ 
        echo 
    "<a href=\"index.php?page=$i\">[$i] </a> ";   
    } 
    }  
    } 
    else if(
    $page<$capped_pages){  
    for (
    $i = $ppage; $i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456  
    if($i<=$total_pages){
        echo 
    "<a href=\"index.php?page=$i\">[$i] </a> ";   
    }
    }  
    }  
      
    else{  
    for (
    $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped))  
        
    echo "<a href=\"index.php?page=$i\">[$i] </a> ";   
    }  
    }  

    if(
    $page<$total_pages){  
    $npage = $page+1;  
    echo 
    "<a href=\"index.php?page=$npage\">Next»</a>";  
    } 

    Leave a comment:


  • wap_king
    replied
    still doesnt work...i thank u for helping i have 10 messages per page and there is only 2 messages on the first page and it that code is showing this

    [][1][2][3][4][5][6]

    Leave a comment:


  • something else
    replied
    PHP Code:
    if($page>1){ 
    $ppage = $page-1; 
    echo 
    "<a href=\"index.php?page=$ppage\">«Prev</a> "; 
    } 
    $capped_pages = $total_pages-4; 
    if(
    $pages<$capped_pages){ 
    for (
    $i = $ppage; $i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456 
        
    echo "<a href=\"index.php?page=$i\">[$i] </a> ";  
    } 
    } 
    else if(
    $page==1){ 
    for (
    $i = $page; $i <= ($page+5); $i++) {  
    if(
    $i<=$total_pages){
        echo 
    "<a href=\"index.php?page=$i\">[$i] </a> ";  
    }
    } 
    } 
    else{ 
    for (
    $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped)) 
        
    echo "<a href=\"index.php?page=$i\">[$i] </a> ";  
    } 
    } 

    if(
    $page<$total_pages){ 
    $npage = $page+1; 
    echo 
    "<a href=\"index.php?page=$npage\">Next»</a>"; 
    } 

    Leave a comment:


  • wap_king
    replied
    having a problem with the code when nothing is on the page its showing [][1][2][3][4][5] its showing that when nothing is on the page i want it to be blank until there is something on the page it will show [1][2]etc....please fix

    Leave a comment:


  • wap_king
    replied
    Originally posted by something else View Post
    PHP Code:
    if($page>1){
    $ppage = $page-1;
    echo 
    "<a href=\"index.php?page=$ppage\">«Prev</a> ";
    }
    $capped_pages = $total_pages-4;
    if(
    $pages<$capped_pages){
    for (
    $i = $ppage; $i <= ($page+5); $i++) {            //previous page added here also ...so if on page 3 it shows pages 23456
        
    echo "<a href=\"index.php?page=$i\">[$i] </a> "; 
    }
    }
    else if(
    $page==1){
    for (
    $i = $page; $i <= ($page+5); $i++) { 
        echo 
    "<a href=\"index.php?page=$i\">[$i] </a> "; 
    }
    }
    else{
    for (
    $i = ($total_pages-5); $i <= ($page+5); $i++) {      //show total pages (dont go over (capped))
        
    echo "<a href=\"index.php?page=$i\">[$i] </a> "; 
    }
    }

    if(
    $page<$total_pages){
    $npage = $page+1;
    echo 
    "<a href=\"index.php?page=$npage\">Next»</a>";
    } 

    thank u so much am going to try it....

    Leave a comment:

Working...
X