Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8941457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:18:23+00:00 2026-06-15T11:18:23+00:00

Currently I’ve 2 tables and have the datas are dynamic. I need to add

  • 0

Currently I’ve 2 tables and have the datas are dynamic.

I need to add pagination for both tables seperately. I had added paginator using paginator class and it is working fine. But the problem is when I click on the next button of the first table then the contents of both tables are changed in to the next page.

Paginator.php

<?php

// Paginator Class
// error_reporting(E_ALL); 

define("QS_VAR", "page"); // the variable name inside the query string (don't use this name inside other links)
define("STR_FWD", "Next&gt;&gt;"); // the string is used for a link (step forward)
define("STR_BWD", "&lt;&lt;Prev"); // the string is used for a link (step backward)

$scriptname = (isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : '');
define("SCRIPT_NAME", $scriptname);
$v = (isset($_REQUEST['page_num_rows']) ? (is_numeric($_REQUEST['page_num_rows']) ? $_REQUEST['page_num_rows'] : 5) : 5);
define("NUM_ROWS", $v); // the number of records on each page

class Paginator {

    var $sql;
    var $result;
    var $get_var = QS_VAR;
    var $rows_on_page = NUM_ROWS;
    var $str_forward = STR_FWD;
    var $str_backward = STR_BWD;  
    var $all_rows;
    var $num_rows;
    var $page;
    var $number_pages;
    var $url_name = SCRIPT_NAME;

    // constructor
    function Paginator() {

    }

    // sets the current page number
    function set_page() {
        $this->page = (isset($_REQUEST[$this->get_var]) && $_REQUEST[$this->get_var] != "") ? $_REQUEST[$this->get_var] : 0;
        return $this->page;
    }

    // gets the total number of records
    function get_total_rows() {
        $tmp_result = mysql_query($this->sql);
        $this->all_rows = mysql_num_rows($tmp_result);
        mysql_free_result($tmp_result);
        return $this->all_rows;
    }

    // get the totale number of result pages
    function get_num_pages() {
        $this->number_pages = ceil($this->get_total_rows() / $this->rows_on_page);
        return $this->number_pages;
    }

    // returns the records for the current page
    function get_page_result() {
        $start = $this->set_page() * $this->rows_on_page;
        $page_sql = sprintf("%s LIMIT %s, %s", $this->sql, $start, $this->rows_on_page);
        $this->result = mysql_query($page_sql);
        return $this->result;
    }

    // get the number of rows on the current page
    function get_page_num_rows() {
        $this->num_rows = @mysql_num_rows($this->result);
        return $this->num_rows;
    }

    // free the database result
    function free_page_result() {
        @mysql_free_result($this->result);
    }

    function display_row_count() {
        $var = $this->get_var;
        $url_part1 = $this->url_name . "?";
        $url_part2 = "&" . $var . "=0" . $this->rebuild_qs($var);
        $select = "&nbsp;&nbsp;Show ";
        $select.="<form method=get name=page_num_rows_form action=\"$this->url_name\" >"; // [form used for javascript disabled case] -not working
        $select.="<select name=page_num_rows id=page_num_rows onChange=\"window.location='$url_part1'+'page_num_rows='+this.value+'$url_part2'\" >";
        $select.="<option value=50 " . (isset($_REQUEST['page_num_rows']) ? ($_REQUEST['page_num_rows'] == 50 ? ' selected ' : '') : '') . " >50</option>";
        $select.="<option value=100 " . (isset($_REQUEST['page_num_rows']) ? ($_REQUEST['page_num_rows'] == 100 ? ' selected ' : '') : '') . " >100</option>";
        $select.="<option value=150 " . (isset($_REQUEST['page_num_rows']) ? ($_REQUEST['page_num_rows'] == 150 ? ' selected ' : '') : '') . " >150</option>";
        $select.="<option value=200 " . (isset($_REQUEST['page_num_rows']) ? ($_REQUEST['page_num_rows'] == 200 ? ' selected ' : '') : '') . " >200</option>";
        $select.="<option value=500 " . (isset($_REQUEST['page_num_rows']) ? ($_REQUEST['page_num_rows'] == 500 ? ' selected ' : '') : '') . " >500</option>";
        $select.="</select>";
        $select.="<noscript>&nbsp;<input type=submit value=Go /></noscript>";
        $select.="</form>";  // form used for javascript disabled case -- not working
        $select.=" per page";
        return $select;
    }

    // function to handle other querystring than the page variable
    function rebuild_qs($curr_var) {
        if (!empty($_SERVER['QUERY_STRING'])) {
            $parts = explode("&", $_SERVER['QUERY_STRING']);
            $newParts = array();
            foreach ($parts as $val) {
                if (stristr($val, $curr_var) == false) {
                    array_push($newParts, $val);
                }
            }
            if (count($newParts) != 0) {
                $qs = "&" . implode("&", $newParts);
            } else {
                return false;
            }
            return $qs; // this is your new created query string
        } else {
            return false;
        }
    }

    // this method will return the navigation links for the conplete recordset
    function navigation($separator = " | ", $css_current = "", $back_forward = false) {
        $max_links = NUM_LINKS;
        $curr_pages = $this->set_page();
        $all_pages = $this->get_num_pages() - 1;
        $var = $this->get_var;
        $navi_string = "";
        if (!$back_forward) {
            $max_links = ($max_links < 2) ? 2 : $max_links;
        }
        if ($curr_pages <= $all_pages && $curr_pages >= 0) {
            if ($curr_pages > ceil($max_links / 2)) {
                $start = ($curr_pages - ceil($max_links / 2) > 0) ? $curr_pages - ceil($max_links / 2) : 1;
                $end = $curr_pages + ceil($max_links / 2);
                if ($end >= $all_pages) {
                    $end = $all_pages + 1;
                    $start = ($all_pages - ($max_links - 1) > 0) ? $all_pages - ($max_links - 1) : 1;
                }
            } else {
                $start = 0;
                $end = ($all_pages >= $max_links) ? $max_links : $all_pages + 1;
            }
            if ($all_pages >= 1) {
                $forward = $curr_pages + 1;
                $backward = $curr_pages - 1;
                $navi_string = ($curr_pages > 0) ? "<a href=\"" . $this->url_name . "?" . $var . "=0" . $this->rebuild_qs($var) . "\">" . $this->str_first . "</a>&nbsp;&nbsp;<a href=\"" . $this->url_name . "?" . $var . "=" . $backward . $this->rebuild_qs($var) . "\">" . $this->str_backward . "</a>&nbsp;&nbsp;" : $this->str_first . "&nbsp;&nbsp;" . $this->str_backward . "&nbsp;&nbsp;";

                $navi_string .= ($curr_pages < $all_pages) ? "&nbsp;&nbsp;<a href=\"" . $this->url_name . "?" . $var . "=" . $forward . $this->rebuild_qs($var) . "\">" . $this->str_forward . "</a>" . "&nbsp;" : "&nbsp;&nbsp;" . $this->str_forward . "&nbsp;&nbsp;";
            }
        }
        return "<span style='font-size:.7em; padding:3px 3px 4px 3px;'>" . $this->current_page_info() . $navi_string . "</span>";
    }

    function current_page_info() {
        $cur_page = $this->set_page() + 1;
        $total_pages = $this->get_num_pages();
//        $page_info = "&nbsp;Page " . $cur_page . " of " . $total_pages . "&nbsp;&nbsp; ";
//        return $page_info;
    }

    function show_go_to_page() {
        $cur_page = $this->set_page() + 1;
        $total_pages = $this->get_num_pages();
        $options = "";
        for ($i = 1; $i <= $total_pages; $i++) {
            $options.="<option value=$i " . (($i == $cur_page) ? ' selected ' : '') . ">$i</option>";
        }
        $page_info = "&nbsp;&nbsp;&nbsp;&nbsp;Go to page <input type=text name=paginator_go_to_page id=paginator_go_to_page size=1 value=$cur_page />";
        // $page_info.= "<select name=paginator_go_to_page2 >$options</select>";
        return $page_info;
    }

}

?>

tables.php

 <?php
    include("library/paginator.php");
    ?>
    <div style="text-align:right;">
        <?
        $query = "select * from haves_settings";
        $tab = mysql_query($query);
        $row = mysql_fetch_array($tab);
        $item_no = $row['items_to_show'];
        $scroll = $row['scroll_interval'];

        $online_paginate = new Paginator;
        $online_paginate->sql = "select * from placing_item_bid where status='Active' and picture1!='' and selling_method!='want_it_now' and selling_method!='ads' and bid_starting_date <= now() and expire_date>=now() order by item_id desc"; // sql statement
        $online_paginate->rows_on_page = $item_no;
        $results = $online_paginate->get_page_result(); // result set
        $num_rows = $online_paginate->get_page_num_rows(); // number of records in result set
        $nav_links = $online_paginate->navigation("&nbsp; | &nbsp;"); // the navigation links (define a CSS class
        ?>
    </div>

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr bgcolor="#d79196" class="detail9txt">
        <input type="hidden" value="2" name="len">
        <td align="center" width="20%"><b>Picture</b> </td>
        <td width="30%" align="center"><b>Name / Responses</b> </td>
        <td width="50%" align="center"><b>Description</b> </td>
    </tr><tr style="height:10px;"><td></td></tr>
    <?
    if ($num_rows > 0) {
        while ($bestsellers_fetch = mysql_fetch_array($results)) {
            $temp = $bestsellers_fetch['item_id'];
            $sql = "SELECT count(`user_id`) as response FROM `watch_list` where `item_id`=$temp group by `item_id`";
            $res = mysql_query($sql);

            $response = mysql_fetch_row($res);

            $counttop = $counttop + 1;
            if (!empty($bestsellers_fetch['sub_title']))
                $item_subtitle1 = $bestsellers_fetch['sub_title'];
            else
                $item_subtitle1 = substr($bestsellers_fetch['item_title'], 0, 20);
            $item_title1 = substr($bestsellers_fetch['item_title'], 0, 40)
            ?>
            <tr>
                <td class="tr_botborder" style="vertical-align:middle;" width="20%" align="center"><div align="center"><a href="detail.php?item_id=<?= $bestsellers_fetch['item_id']; ?>" class="bestsellerstxt"><img src="thumbnail/<?= $bestsellers_fetch['picture1']; ?>" alt="" width="79" height="70" border="0" /></a></div></td>
                <td class="tr_botborder" style="vertical-align:middle;" width="30%" align="center"><div align="center"><span class="bestsellerstxt"><a href="detail.php?item_id=<?= $bestsellers_fetch['item_id']; ?>" class="bestsellerstxt"><?= $item_subtitle1; ?> <?= $item_title1; ?></a><br/><?php if ($response[0] != '') { ?><a style="text-decoration:none;color:#336666;" href="detail.php?item_id=<?= $bestsellers_fetch['item_id']; ?>"> <?php echo $response[0] . '&nbsp;responses'; ?></a> <?php } else { ?><span style="color:#666666;"><?php
                echo '0&nbsp;responses';
            }
            ?></span></span></td>
                <td class="tr_botborder" style="vertical-align:middle;" width="50%" align="center"><div align="center"><span class="bestsellerstxt"><a href="#" class="bestsellerstxt"><?= html_entity_decode($bestsellers_fetch['detailed_descrip']); ?></a></span></td>
            </tr>

            <?
            if ($counttop != 2) {

            }
        }
    } else {
        ?>
        <tr><td height="148" align="center" class="featxt">No Items Available</td></tr>
        <?
    }
    ?>
    </table>
    <div style="text-align: right;"><?php echo $nav_links; ?></div>

//wants content

$online_paginate1 = new Paginator;
$online_paginate1->sql = "select * from placing_item_bid where status='Active' and selling_method='want_it_now' order by item_id desc";
$online_paginate1->rows_on_page = $item_no1;
$result1 = $online_paginate1->get_page_result(); // result set
$want_total_records = $online_paginate1->get_page_num_rows(); // number of records in result set
$nav_links1 = $online_paginate1->navigation("&nbsp; | &nbsp;"); // the navigation links (define a CSS class
?>

<div class="superbg">
    <table cellspacing="0" cellpadding="5" width=100%>
        <form name="want_form" action="myauction.php" method=post>
            <tr bgcolor="#d79196" class="detail9txt">
            <input type="hidden" name="len" value="<?= $want_total_records ?>">
            <td align="center" width="30%"><b>Name / Responses</b> </td>
            <td align="center" width="20%"><b>Picture</b> </td>
            <td width="50%" align="center"><b>Description</b>  </td>
            </tr>
            <?
            if ($want_total_records > 0) {
                while ($want_row = mysql_fetch_array($result1)) {
                    $tot_bid_sql = "select count(*) from want_it_now where wanted_itemid=" . $want_row[item_id];
                    $tot_bid_res = mysql_query($tot_bid_sql);
                    $tot_bids = mysql_fetch_array($tot_bid_res);
                    ?>

                    <tr class="detail9txt">
                        <td class="tr_botborder" align="center" style="vertical-align:middle;" width="30%">
                            <a href="wantitnowdes.php?item_id=<?= $want_row['item_id'] ?>" class="header_text">
                                <? echo $want_row['item_title']; ?></a> <br/> <?
                        if ($tot_bids[0] != 0) {
                                    ?>
                                <a style="font-weight:normal;" href="wantitnowdes.php?item_id=<?= $want_row['item_id'] ?> " class="header_text"><? echo $tot_bids[0] . ' responses'; ?></a>
                                <?
                            } else {
                                echo $tot_bids[0] . ' responses';
                            }
                            ?></td>
                        <td class="tr_botborder" style="vertical-align:middle;" width="20%" align="center">
                            <?
                            if (!empty($want_row['picture1'])) {
                                $img = $want_row['picture1'];
                                list($width, $height, $type, $attr) = getimagesize("images/$img");
                                $h = $height;
                                $w = $width;
                                if ($h > 50) {
                                    $nh = 50;
                                    $nw = ($w / $h) * $nh;
                                    $h = $nh;
                                    $w = $nw;
                                }
                                if ($w > 50) {
                                    $nw = 50;
                                    $nh = ($h / $w) * $nw;
                                    $h = $nh;
                                    $w = $nw;
                                }
                                ?>
                                                                                                                                                                                                                    <!-- <img name="runimg" src="images/<? //echo $want_row['picture1'];                                                          ?>" border=1 width=<? //= $w;                                                          ?> height=<? //=$h                                                         ?> >-->
                                <a href="wantitnowdes.php?item_id=<?= $want_row['item_id'] ?> " class="header_text"><img name="runimg" src="images/<? echo $want_row['picture1']; ?>" border=1 width="79" height="70" ></a>
                                <?
                            } else {
                                ?>
                                <img src="images/no_image.gif" border=1  name="runimg" >
                            <? } ?>
                        </td>
                        <td class="tr_botborder" style="vertical-align:middle;" width="50%" align="center"><div align="center"><span class="bestsellerstxt"><a href="#" class="bestsellerstxt"><?= html_entity_decode($want_row['detailed_descrip']); ?></a></span></td>
                    </tr>

                    <?
                } // while
            } else {
                ?>
                <tr>
                    <td width="3%">&nbsp;</td>
                    <td width="97%" class="myauction3txt">There are no items in this section</td>
                </tr>
            <? } ?>

    </table>
    <div style="text-align: right;"><?php echo $nav_links1; ?></div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:18:24+00:00Added an answer on June 15, 2026 at 11:18 am

    Where is the problem ?

    Paginator class uses the same query string “page” parameter to calculate the current page. If you add 2 or more Pagination in the same request, “page” will be shared by all instances, leading to this mess you described.

    How to fix it ?

    Tell the Paginator class which parameter to use in query string… follow this 2-step patch below :

    Step 1 : replace constructor in Paginator class

    // constructor
    function Paginator($get_var=null) {
        if ($get_var!=null) $this->get_var = $get_var;
    }
    

    Step 2 : update Paginator object creation (twice)

    $online_paginate = new Paginator('page_table1');
    

    and later :

    $online_paginate1 = new Paginator('page_table2');
    

    Hope this helps !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have the following Mapping in my Controller: @RequestMapping( value = /add.html, method
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently I am creating VBA Macros for Excel and recently have started using UserForms.
I have thousands of HTML files to process using Groovy/Java and I need to
Currently I am using Microsoft Sync Framework to synchronize databases. I need to gather
Currently I am using HTML files for parts of my user interface. I display
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently, I'm working on a project where I have a server - client relationship
Currently I have 2 ways of displaying images in a cell, which way will
Currently I have this code: <?php echo '<meta name=robots content=noindex>'; $arr = json_decode(file_get_contents(http://media1.clubpenguin.com/play/en/web_service/game_configs/ paper_items.json),true);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.