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 8874309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:41:15+00:00 2026-06-14T18:41:15+00:00

I have a pagination method that is working to a point. If I navigate

  • 0

I have a pagination method that is working to a point. If I navigate beyond page 2, or use my Previous or Next button, my current page and total page variables are appended to the URL, resulting in something like this:

http://localhost/project/profile.php?s=0&p=2&s=1&p=2&select_genre=Sci-Fi&select_length=1-25&query=Submit

Notice the extra s and p assignments

$s defines the starting page
$p defines total pages

Is there a way to prevent the values of $s and $p from appending to the URL?

I’m sure the problem is in how I carry the GET values across the pages in the URL below, I’m not sure how to correct it:

if($pages > 1)
{
    echo '<br /><p>'; //Add some extra space

    $current_page = ($start/$display) + 1;

    //If it's not the first page, make a PREV button

    if($current_page != 1)
    {
        echo '<a href=profile.php?s=' . ($start - $display) . '&p=' . $pages . '&' . http_build_query($_GET) . '"> Previous</a> ';
    }

    //Make all the numbered pages:

    for ($i = 1; $i <= $pages; $i++)
    {
        if($i != $current_page)
        {
            echo '<a href="profile.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '&' . http_build_query($_GET) . '">' . $i . '</a>';
        }
        else {
                 echo $i . ' ';
             }
    }//END FOR LOOP

    // If it's not the last page, make a Next button:

    if ($current_page != $pages)
    {
        echo '<a href="profile.php?s=' . ($start + $display) . '&p=' . $pages . '&' . http_build_query($_GET) . '"> Next</a>';
    }

    echo '</p>'; 
} 

Thanks!

  • 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-14T18:41:16+00:00Added an answer on June 14, 2026 at 6:41 pm

    Well if $_GET contains s or p you you would end-up with doubling those:

    $clean = $_GET;
    unset($clean['p']);    
    unset($clean['s']);
    echo '/someurl?' . http_build_query($clean);
    

    Something like that should work

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

Sidebar

Related Questions

I currently have pagination functionality that displays the total page count, but I was
I have the following method that creates and returns markup for my pagination links
I have a current implementation of will_paginate that uses the paginate_by_sql method to build
I have an application with associations and will pagination the pages. The index page
I have a JSF page that displays a table from an object called TableQuery
On my website I use a pagination (similar to that one on the bottom
I have a page with a form that contains five selects (drop-down lists) which
I was working with getResources and getPages for pagination. Now, I have a requirement
I have a view spec that was passing but is broken now that pagination
I have a p:dataGrid of primefaces that has a pagination on top of the

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.