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

  • Home
  • SEARCH
  • 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 6893589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:40:39+00:00 2026-05-27T06:40:39+00:00

Possible Duplicate: PHP & MySQL Pagination Update Help So, in my site, there are

  • 0

Possible Duplicate:
PHP & MySQL Pagination Update Help

So, in my site, there are 10 pages. In each page I want to show different rows from my table. (I am using MySQL for database and I got table called “A”.)

My rows from table in first page:

$result = mysql_query("SELECT * FROM A ORDER BY date DESC LIMIT 20");

My pages:

<div class="pagenavi" > 
    <span class="pages"><span><a href="index.php"><</a></span>
    <span class="currentpage">1</span> -
    <a href="/pages/page2.php">2</a> -
    <a href="/pages/page3.php">3</a> - 
    <a href="/pages/page4.php">4</a> -  
    <a href="/pages/page5.php">5</a> -
    <a href="/pages/page6.php">6</a> -
    <a href="/pages/page7.php">7</a> - 
    <a href="/pages/page8.php">8</a> -
    <a href="/pages/page9.php">9</a> -
    <a href="/pages/page10.php">10</a>
    <span id="nextpage"><a href="/pages/page2.php" class="arrow">></a></span>
    </span>
</div>

So, in different pages, I can show different rows by changing the limit value, but every time, it goes to another page, not efficient. What I want is that, to show different rows in same page without going another page(for example index.php). If those links were buttons, there would be no problem, but they are not. What can I do?

  • 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-05-27T06:40:40+00:00Added an answer on May 27, 2026 at 6:40 am

    this can be implemented in a better way. You do not not need to make 10 different PHP scripts but you can do this dynamically using GET variables. Here is a code snippet that explains more:

    <?php
    $recPerPage = 20; // number of records per page
    $maxPages = 10; // maximum number of pages
    if (!isset($_GET['page'])) {
        $pn = 1;
    } else {
        $pn = (int) $_GET['page'];
    }
    if ($pn < 1) {
        $pn = 1;
    }
    $offset = ($pn - 1) * $recPerPage;
    $result = mysql_query("SELECT * FROM A ORDER BY date DESC LIMIT " . $offset . ',' . $recPerPage);
    // ... DB code or other processing
    // ...
    
    // now let's dynamically generate the page numbers
    $arrPage = Array();
    for ($i = 1; $i <= $maxPages; $i++) {
        if ($i == $pn) {
            $arrPage[] = '<span class="currentpage">' . $i . '</span>';
        } else {
            $arrPage[] = '<a href="/temp/index.php?page=' . $i . '">' . $i . '</a>';
        }
    }
    $prevPn = ($pn - 1) < 1 ? 1 : ($pn - 1);
    $nextPn = ($pn + 1) > $maxPages ? $maxPages : ($pn + 1);
    ?>
    <div class="pagenavi" > 
        <span class="pages">
            <span><a href="/temp/index.php?page=<?php echo $prevPn; ?>" class="arrow"><</a></span>
            <?php echo implode(' - ', $arrPage); ?>
            <span id="nextpage"><a href="/temp/index.php?page=<?php echo $nextPn; ?>" class="arrow">></a></span>
        </span>
    </div>
    

    Hope this helps!

    And yes, all the page links now point to index.php.

    There is one thing though that I would like to ask. Why do you say there will be no problem if the links were buttons?

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

Sidebar

Related Questions

Possible Duplicate: php regular expression help? hi, i want to replace i like apple
Possible Duplicate: PHP pagination class are there any PHP/Class libraries that i can utilize
Possible Duplicate: Reference: Comparing PHP's print and echo Is there any major and fundamental
Possible Duplicate: Is there a php library for email address validation? Hi there, I
Possible Duplicate: highlighting search results in php/mysql I am doing a search with a
Possible Duplicate: insert multiple rows via a php array into mysql I know about
Possible Duplicate: php echo vs open&close tag For example. Is this: <p>Hello welcome to
Possible Duplicate: sending mail with php & escaping hotmails junk folder I have been
Possible Duplicate: Converting ereg expressions to preg <?php $searchtag = "google"; $link = "http://images.google.com/images?hl=de&q=$searchtag&btnG=Bilder-Suche&gbv=1";
Possible Duplicate: PHP: How to generate a random, unique, alphanumeric string? i want to

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.