pagenation bug found

Discussion in 'General Support' started by skyhigh, Jul 31, 2018.

  1. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I am throwing in the towel. I am afraid I will never understand what you are saying here. I totally give up! Take a snapshot of the page or speak proper English here so, people can understand you here. What I posted in post #19, there's no pagination for the code comparison and I am not going to sit here and waste another two weeks trying my best to understand what you are trying to say here. Plus your codes are old from 2016. Maybe if you upgrade your pages it might work instead of working with older codes. I'm done with this thread. Hopefully someone else can help you here.
     
  2. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,327
    Likes Received:
    449
    That is because admin list code it does not use the search details in the pagination.
    Pagination looks like it reverts to the standard listing listusers.php?PAGE=2 and disregards any searching.( It should be something like: listusers.php?usersfilter=active&PAGE=2
    In listusers.php you would need to add the "usersfilter" in the pagination if any. New 1.2.2.2 uses a session var too ($_SESSION['usersfilter']) which should in theory bring up only the searched items, but unable to test if it works as not enough users on my testing site.
     
  3. skyhigh

    skyhigh Member

    Joined:
    Sep 28, 2010
    Messages:
    449
    Likes Received:
    8
    hi thanks for getting what have been trying to explain am using 1.21 added d search but that bug is just too big to ignore plz heres d full code below will b glad if u take a look at it for me thanks n definitely paste it here for people to use also

    php code
    PHP:
    <?php
    /***************************************************************************
     *  copyright         : (C) 2008 - 2016 WeBid
     *  site           : http://www.webidsupport.com/
     ***************************************************************************/

    /***************************************************************************
     *  This program is free software; you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation; either version 2 of the License, or
     *  (at your option) any later version. Although none of the code may be
     *  sold. If you have been sold this script, get a refund.
     ***************************************************************************/
    define('InAdmin'1);
    $current_page 'auctions';
    include 
    '../common.php';
    include 
    INCLUDE_PATH 'functions_admin.php';
    include 
    'loggedin.inc.php';


    // check if looking for users auctions
    $uid = isset($_GET['uid']) ? intval($_GET['uid']) : 0;
    $user_sql = isset($_GET['uid']) ? " AND a.user = " $uid '';

    // Set offset and limit for pagination
    if (isset($_GET['PAGE']) && is_numeric($_GET['PAGE']))
    {
       
    $PAGE intval($_GET['PAGE']);
       
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    }
    elseif (isset(
    $_SESSION['RETURN_LIST_OFFSET']) &&
       (isset(
    $_SESSION['RETURN_LIST']) && $_SESSION['RETURN_LIST'] == 'listauctions.php'))
    {
       
    $PAGE intval($_SESSION['RETURN_LIST_OFFSET']);
       
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    }
    else
    {
       
    $OFFSET 0;
       
    $PAGE 1;
    }

    $_SESSION['RETURN_LIST'] = 'listauctions.php';
    $_SESSION['RETURN_LIST_OFFSET'] = $PAGE;

    $query "SELECT COUNT(a.id) as auctions FROM " $DBPrefix "auctions a
       LEFT JOIN " 
    $DBPrefix "auction_moderation m ON (a.id = m.auction_id)
       WHERE m.reason IS NULL AND a.closed = 0 " 
    $user_sql;
    $db->direct_query($query);
    $num_auctions $db->result('auctions');
    $PAGES = ($num_auctions == 0) ? ceil($num_auctions $system->SETTINGS['perpage']);

    // Retrieve close games from the database
    $params = array();

       
    $keyword $system->cleanvars($_POST['keyword']);
       
    $query "SELECT a.*, u.nick, u.id AS nick_id, c.cat_name FROM " $DBPrefix "auctions a

         LEFT JOIN " 
    $DBPrefix "users u ON (u.id = a.user)
         LEFT JOIN " 
    $DBPrefix "categories c ON (c.cat_id = a.category)
       WHERE a.closed = 0 AND (a.title LIKE :title OR a.artistname LIKE :artistname OR  a.id LIKE :id) ORDER BY a.starts desc LIMIT :OFFSET, :perpage"
    ;
       
    $params[] = array(':title''%' $keyword '%''int');
       
    $params[] = array(':artistname''%' $keyword '%''int');
       
    $params[] = array(':id''%' $keyword '%''int');

       


    $params[] = array(':OFFSET'$OFFSET'int');
    $params[] = array(':perpage'$system->SETTINGS['perpage'], 'int');
    $db->query($query$params);
    $TOTALUSERSS $db->result('COUNT');


    $params = array();

       
    $query "SELECT a.*, u.nick, u.id AS nick_id, c.cat_name FROM " $DBPrefix "auctions a

         LEFT JOIN " 
    $DBPrefix "users u ON (u.id = a.user)
         LEFT JOIN " 
    $DBPrefix "categories c ON (c.cat_id = a.category)
       WHERE a.closed = 0 AND (a.title LIKE :title OR a.artistname LIKE :artistname OR  a.id LIKE :id) ORDER BY a.starts desc LIMIT :OFFSET, :perpage"
    ;
       
    $params[] = array(':title''%' $keyword '%''int');
       
    $params[] = array(':artistname''%' $keyword '%''int');
       
    $params[] = array(':id''%' $keyword '%''int');
       
    $params[] = array(':OFFSET'$OFFSET'int');
    $params[] = array(':perpage'$system->SETTINGS['perpage'], 'int');

    $db->query($query$params);

    while (
    $row $db->fetch())
    {
       
    $template->assign_block_vars('auctions', array(
           
    'SUSPENDED' => $row['suspended'],
           
    'ARTISTNAME' => $row['artistname'],
           
    'STUDIO_PICK' => $row['studio_pick'],
           
    'TIMESREPORTED' => $row['times_reported'],
           
    'IN_MODERATION_QUEUE' => !is_null($row['reason']),
           
    'ID' => $row['id'],
           
    'TITLE' => htmlspecialchars($row['title']),
           
    'START_TIME' => ArrangeDateNoCorrection($row['starts'] + $system->tdiff),
           
    'END_TIME' => ArrangeDateNoCorrection($row['ends'] + $system->tdiff),
           
    'USERNAME' => $row['nick'],
           
    'CATEGORY' => $row['cat_name'],
           
    'B_HASWINNERS' => false,
           
    'BG' => $bg
           
    ));
       
    $bg = ($bg == '') ? 'class="bg"' '';
       
    $username $row['nick'];
    }


    // this is used when viewing a users auctions
    if ((!isset($username) || empty($username)) && $uid 0)
    {
       
    $query "SELECT nick FROM " $DBPrefix "users WHERE id = :user_id";
       
    $params = array();
       
    $params[] = array(':user_id'$uid'int');
       
    $db->query($query$params);
       
    $username $db->result('nick');
    }

    // get pagenation
    $PREV intval($PAGE 1);
    $NEXT intval($PAGE 1);
    if (
    $PAGES 1)
    {
       
    $LOW $PAGE 5;
       if (
    $LOW <= 0$LOW 1;
       
    $COUNTER $LOW;
       while (
    $COUNTER <= $PAGES && $COUNTER < ($PAGE 6))
       {
         
    $template->assign_block_vars('pages', array(
             
    'PAGE' => ($PAGE == $COUNTER) ? '<b>' $COUNTER '</b>' '<a href="' $system->SETTINGS['siteurl'] . 'admin/listauctions.php?PAGE=' $COUNTER '"><u>' $COUNTER '</u></a>'
             
    ));
         
    $COUNTER++;
       }
    }

    $template->assign_vars(array(
         
    'PAGE_TITLE' => $MSG['067'],
         
    'NUM_AUCTIONS' => $num_auctions,
         
    'B_SEARCHUSER' => ($uid 0),
         
    'USERNAME' => $username,

         
    'PREV' => ($PAGES && $PAGE 1) ? '<a href="' $system->SETTINGS['siteurl'] . 'admin/listauctions.php?PAGE=' $PREV '"><u>' $MSG['5119'] . '</u></a>&nbsp;&nbsp;' '',
         
    'NEXT' => ($PAGE $PAGES) ? '<a href="' $system->SETTINGS['siteurl'] . 'admin/listauctions.php?PAGE=' $NEXT '"><u>' $MSG['5120'] . '</u></a>' '',
         
    'PAGE' => $PAGE,
         
    'PAGES' => $PAGES
         
    ));


    include 
    'header.php';
    $template->set_filenames(array(
         
    'body' => 'listauctions.tpl'
         
    ));
    $template->display('body');
    include 
    'footer.php';
    ?>


    tpl code
    PHP:
        <div style="width:25%; float:left;">
           <
    div style="margin-left:auto; margin-right:auto;">
             <!-- INCLUDE 
    sidebar-{CURRENT_PAGE}.tpl -->
           </
    div>
         </
    div>
         
         <
    BIG>
         <
    div style="width:75%; float:right;">
           <
    div class="main-box">
             <
    h4 class="rounded-top rounded-bottom">{L_239}&nbsp;&gt;&gt;&nbsp;{PAGE_TITLE}</h4>
             <
    div class="plain-box">{TOTALUSERS}  {NUM_AUCTIONS} {L_311}<!-- IF B_SEARCHUSER --> {L_934}{USERNAME}<!-- ENDIF --></div>
             <
    form name="search" action="" id="myformlist" method="post">
                   <
    input type="hidden" name="csrftoken" value="{_CSRFTOKEN}">
                      <
    input type="text" name="keyword" size="25">
                   <
    input type="submit" name="submit" value="{L_5023}">
            </
    form>
             <
    table width="98%" cellpadding="0" cellspacing="0">
             <
    tr>
              <
    th align="center">&nbsp;</th>
               <
    th align="center">Artist Name </th>
               <
    th align="center"><b>{L_017}</b></th>
               <
    th align="center"><b>{L_557}</b></th>
               <
    th align="left"><b>{L_297}</b></th>
             <
    tr>
             <!-- 
    BEGIN auctions -->
             <
    tr {auctions.BG}>
               <
    td>[ <a href="{SITEURL}item.php?id={auctions.ID}" target="_blank">{L_5295}</a> ]<br />
               {
    auctions.ID}           </td>
               <
    td>
                 <!-- IF 
    auctions.SUSPENDED -->
                 <
    span style="color:#FF0000">{auctions.ARTISTNAME}</span><br>
                 <!-- ELSE -->
                   <!-- IF 
    auctions.TIMESREPORTED -->
                   <
    span style="color:#FFA500">{auctions.ARTISTNAME}</span><br>
                   <!-- ELSE -->
                   {
    auctions.ARTISTNAME}<br>

                   <!-- ENDIF -->
                 <!-- ENDIF -->
                 <
    p>&nbsp;</p>             </td>
               <
    td><!-- IF auctions.SUSPENDED -->
      <
    span style="color:#FF0000">{auctions.TITLE}</span><br />
      <!-- ELSE -->
      <!-- IF 
    auctions.TIMESREPORTED -->
      <
    span style="color:#FFA500">{auctions.TITLE}</span><br />
      <!-- ELSE -->
                {
    auctions.TITLE}<br />
      <!-- ENDIF -->
      <!-- ENDIF -->
      <
    p>&nbsp;</p></td>
               <
    td>
                 <
    b>{L_003}:</b> {auctions.USERNAME}<br>
                 <
    b>{L_625}:</b> {auctions.START_TIME}<br>
                 <
    b>{L_041}:</b> {auctions.CATEGORY}           </td>
               <
    td align="left">
                 <
    a href="editauction.php?id={auctions.ID}&offset={PAGE}">{L_298}</a><br>
                 <
    a href="deleteauction.php?id={auctions.ID}&offset={PAGE}">{L_008}</a><br>
                 <
    a href="excludeauction.php?id={auctions.ID}&offset={PAGE}">
               <!-- IF 
    auctions.SUSPENDED eq 0 -->
                 {
    L_300}
               <!-- ELSE -->
                 {
    L_310}
               <!-- ENDIF -->
                 </
    a>
               <!-- IF 
    auctions.IN_MODERATION_QUEUE -->
                 <
    br><a href="removefrommoderation.php?id={auctions.ID}&offset={PAGE}">{L_moderator_dismiss}</a>
               <!-- ENDIF -->
               <!-- IF 
    auctions.B_HASWINNERS -->
                 <
    br><a href="viewwinners.php?id={auctions.ID}&offset={PAGE}">{L__0163}</a>
               <!-- ENDIF -->           </
    td>
             </
    tr>
             <!-- 
    END auctions -->
             </
    table>
             <
    table width="98%" cellpadding="0" cellspacing="0" class="blank">
               <
    tr>
                 <
    td align="center">
                   {
    L_5117}&nbsp;{PAGE}&nbsp;{L_5118}&nbsp;{PAGES}
                   <
    br>
                   {
    PREV}
    <!-- 
    BEGIN pages -->
                   {
    pages.PAGE}&nbsp;&nbsp;
    <!-- 
    END pages -->
                   {
    NEXT}
                 </
    td>
               </
    tr>
             </
    table>
           </
    div>
         </
    div>
         </
    BIG>
    thanks
     
  4. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,145
    Likes Received:
    247
    I will give this one more try.

    Where did you get the codes from? I don't remember seeing these VARS.
    'ARTISTNAME' => $row['artistname'],
    'STUDIO_PICK' => $row['studio_pick'],

    Try replacing this table code on the bottom of the .tpl page:

    HTML:
    <table width="98%" cellpadding="0" cellspacing="0" class="blank">
               <tr>
                 <td align="center">
                   {L_5117}&nbsp;{PAGE}&nbsp;{L_5118}&nbsp;{PAGES}
                   <br>
                   {PREV}
    <!-- BEGIN pages -->
                   {pages.PAGE}&nbsp;&nbsp;
    <!-- END pages -->
                   {NEXT}
                 </td>
               </tr>
    With:

    HTML:
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td align="center">
                <small><span class="text-muted">{L_5117}&nbsp;{PAGE}&nbsp;{L_5118}&nbsp;{PAGES}</span></small>
                <nav>
                    <ul class="pagination">
                        <br>
                        <li>{PREV}</li>
    <!-- BEGIN pages -->
                        <li>{pages.PAGE}</li>
    <!-- END pages -->
                        <li>{NEXT}</li>
                    </ul>
                </nav>
            </td>
        </tr>
    </table>
     

Share This Page