Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pagination Problem

    I have been racking my brains out for 2 days now with this.

    I have the paging script in this php file and this is for the members section of my site.

    When it shows all members it works correctly with the exception of a number "1" next to the "Last" Box and I cannot figure out where that problem is.

    Also I have this set up to where members can "view all members" or "view only members with avatars". When you click to view only members with avatars it shows the correct first page of members with avatars but it shows the incorrect members with avatars count from the database and when you click another page it snaps back to the viewing all members pages.

    I have attached a picture of what it looks like and here is the php code.

    I would greatly appreciate it if someone can help me see where I am going wrong.

    PHP Code:
    <?php
    session_start
    ();

    if ( !isset(
    $_SESSION['view_video']) || $_SESSION['view_video'] == false )
    {
       
    header('Location: ../');
    }
    include(
    "include/config.php");
    include(
    "include/function.php");

    if (
    $_SESSION['lang'] == ""){
      include(
    "language/en.php");
    } else {
      include(
    "language/".$_SESSION['lang'].".php");
    }  

    $currentpage 1;
        
    $getcurrentpage=$_REQUEST['page'];
        if (
    $getcurrentpage >= 1$currentpage $getcurrentpage;

    //PAGING
    if($_REQUEST[page]=="")
    $page 1;
    else
    $page $_REQUEST[page];

    $sql "SELECT count(*) as total from signup where account_status='Active' order by UID desc";

    $ars $conn->Execute($sql);
    if(
    $ars->fields['total']<=$config[total_per_ini])$total $ars->fields['total'];
    else 
    $total $config[total_per_ini];
    $tpage ceil($total/$config[items_per_page]);
    if(
    $tpage==0$spage=$tpage+1;
    else 
    $spage $tpage;
    $startfrom = ($page-1)*$config[items_per_page];
    //generate next and previous



    $sql="SELECT * from signup where account_status='Active' order by UID desc limit $startfrom, $config[items_per_page]";



    if(
    $_REQUEST[type]=="avatar")

    {

    $sql="SELECT * from signup where account_status='Active' and photo != '' order by UID desc limit $startfrom, $config[items_per_page]";

    }

    else

    {

    $sql="SELECT * from signup where account_status='Active' order by UID desc limit $startfrom, $config[items_per_page]";

    }



    $rs $conn->Execute($sql);

    $users $rs->getrows();

    $start_num=$startfrom+1;

    $page_link="";
    $k=1;
    $theprevpage=$currentpage-1;
    $thenextpage=$currentpage+1;

    if (
    $currentpage 0)
    {
        
    $page_link.="<ul class=\"pagination\">";
        
        
    $page_link.="<li class=\"blankpage\"></li>&nbsp;&nbsp;";
        
        if(
    $currentpage 1
        {
        
        
    $page_link.="<li class=\"previous\"><a href='users.php?page=$theprevpage'> &laquo; Previous</a></li>&nbsp;&nbsp;";
        
    $page_link.="<li class=\"last\"><a href='users.php?page=1'>First</a></li>&nbsp;&nbsp;";
        };
        
        
    $counter=0;
        
        
    $lowercount $currentpage-5;
        if (
    $lowercount <= 0$lowercount 1;
        
        while (
    $lowercount $currentpage)
        {
            
    $page_link.="<li><a href='users.php?page=$lowercount'>$lowercount</a></li>&nbsp;&nbsp;";
            
    $lowercount++;
            
    $counter++;
        }
        
        
    $page_link.="<li class=\"current\">$currentpage</li>&nbsp;&nbsp;";
        
        
    $uppercounter $currentpage+1;
        
        while ((
    $uppercounter $currentpage+3-$counter) && ($uppercounter<=$tpage))
        {
            
    $page_link.="<li><a href='users.php?page=$uppercounter'>$uppercounter</a></li>&nbsp;&nbsp;";
            
    $uppercounter++;
        }
        
        if(
    $currentpage $tpage
        {
        
        
    $page_link.="<li class=\"last\"><a href='users.php?page=$tpage'>Last</a></li>&nbsp;&nbsp;";
        
    $page_link.="<li class=\"next\"><a class=\"pagingbox\" href='users.php?page=$thenextpage'>Next &raquo;</a></li>&nbsp;&nbsp;";
        };
        
        
    $page_link.="</ul>";

    }

    //END PAGING







            

    if(
    $_REQUEST[type]=="avatar")

    {

    $page_link.="<a style='font-size:10px; font-family: Verdana,Arial,Tahoma; weight: bold;' href='users.php?type=avatar&page=$k'><strong>$k</strong></a>&nbsp;&nbsp; ";

    }

    else

    {

    $page_link.="<a style='font-size:10px; font-family: Verdana,Arial,Tahoma; weight: bold;' href='users.php?page=$k'><strong>$k</strong></a>&nbsp;&nbsp; ";

    }

    }



    //END PAGING


    STemplate::assign('next',$next);
    STemplate::assign('prev',$prev);
    STemplate::assign('err',$err);
    STemplate::assign('msg',$msg);
    STemplate::assign('page',$page);
    STemplate::assign('start_num',$start_num);
    STemplate::assign('end_num',$end_num);
    STemplate::assign('placement',$placement);
    STemplate::assign('page_link',$page_link);
    STemplate::assign('total',$total);
    STemplate::assign('answers',$users);
            
    STemplate::display('head1.tpl');
            
    STemplate::display('err_msg.tpl');

            
    STemplate::display('users.tpl');

            
    STemplate::display('footer1.tpl');
    ?>
    Attached Thumbnails Attached Thumbnails Pagination Problem-viewingall.jpg  

  • #2
    Banned
    Join Date
    Oct 2003
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind I figured it out while waiting.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •