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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:12:41+00:00 2026-05-31T19:12:41+00:00

I have set up the following: Database class ($db) Pagination class ($paginator) I am

  • 0

I have set up the following:

  1. Database class ($db)
  2. Pagination class ($paginator)

I am attempting to write a basic system to let me administrate pages. I have a page “page_manager.php” in which I include both my database class (database.php) and my pagination class (paginate.php).

In my pagination class I have a function which echoes my SQL data. I’ve come up with a way to echo an HTML < select > element with the necessary IDs, which allows me to successfully echo the corresponding results (10 per page), based on the value of the < select > element. So, “1” will echo the first 10 results in the database, “2” will echo from 11-20, “3” will echo from 21-30, etc., etc..

I have added an onChange event to the < select > element which will copy its value (using “this.value”) to a hidden form field. I then submit this form using document.getElementById().submit();

This will then add the $_GET variable to the URL, so the URL becomes “…/?pagenumber_form=X”. However, when I try to grab this value back from the URL, the $_GET[‘pagenumber_form’] is empty.

Some code:

<span style='font-family: tahoma; font-size: 10pt;'>Page #</span>
    <select id="page_number_selection" 
    onchange='javascript: document.getElementById("pagenumber_form").value = this.value;
                          document.getElementById("pagenumber").submit();'>
    <?php
        for($i = 1; $i <= $this->num_pages; $i++)
            echo"<option id='" . $i . "'>" . $i . "</option>";      
    ?>
    </select>

<form name="pagenumber" id="pagenumber" action="" method="get">
    <input type="text" name="pagenumber_form" id="pagenumber_form" />
</form>

So, I’ve tried using $_POST as well, but the same thing happens. I want to use $_GET, for a couple of reasons: it’s easier to see what is happening with my values and the data I’m using doesn’t need to be secure.

To recap: the $_GET variable is being added to the URL when I change the < select > element, and the corresponding value gets added to the URL as: “…/?pagenumber_form=X”, but when I try to use the value in PHP, for example…

$page_number = $_GET['pagenumber_form'];

… I get a NULL value. 🙁

Can anybody help me out please? Thank you.

EDIT:

I’ve just made a discovery. If I move my print_r($_GET) to my main index page, then the superglobals are returning as expected. My site structure is like this:

index.php
– JavaScript buttons use AJAX HTTP requests to include the “responseText” as the .innerHTML of my main < div >. The “responseText” is the contents of the page itself, in this case page_manager.php, which in turn includes pagination.php.

So in other words, my site is built from PHP includes, which doesn’t seem to be compatible with HTTP superglobals.

Any idea how I can get around this problem? Thank you :-).

+——————————————————————+

I can’t answer my own posts, so:

The problem is not solved, but has been worked around.

I am certainly not very knowledgeable when it comes to PHP, but I am of the impression that using AJAX requests to include a PHP file in a document, which itself includes other PHP files, is not a good idea. The problem, I believe, was being caused because PHP is executed before the document is loaded in to the browser. Therefore, dynamically including a PHP file in a document will result in the improper working of said file due to the fact that PHP must be executed by the server before the page is rendered, and not after.

As such, I have stopped using AJAX for my site and am simply using good old PHP instead. I don’t know enough to carry on using the AJAX requests, so that’s an end to that problem.

Thanks to those who replied.

  • 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-31T19:12:42+00:00Added an answer on May 31, 2026 at 7:12 pm

    You need to re-pass the superglobals to the AJAX calls. So where you would make a request to pagination.php you need to make it to pagination.php?pagenumber_form=<?php echo $_GET['pagenumber_form']; ?>.

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

Sidebar

Related Questions

Suppose the following: I have a database set up on database.mywebsite.com , which resolves
I have the following database tables/EF objects public class Transaction { //some other properties
I have the following structure otsg > class > authentication.php > database.php > user.php
I have the following set of tables in an existing database. Resource - ResourceID
I'm trying to map a Dictionary containing Lists. I have the following set of
I'm using log4Net for my logging. I also have the following set... <log4net debug=true>
I have implemented the following set up (after being requested): slideshow of images changing,
I have just set up ruby in Aptana studio and am getting the following
I have a set of vertically ordered elements. They are displayed with the following
I'm trying to do the following: I have a set of images and select

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.