Solved

$_GET inside a PHP class

Posted on 2010-11-29
3
657 Views
Last Modified: 2012-05-10
I have a theoretical question about a class construction in PHP.

Let's say i want to build a pagination class and i want to handle user input inside the class
(buttons - Next, Prev). I imagine i would have to call the script again $PHP_SELF when pressing
next or Prev button, and then through $_GET display the required set of records, so can I
construct my script like this example:

 <html>
  ..  header etc.

 <?php
 require_once   'paginate.php';
   mypagination = new Page;  

   PAge->display();


 ?>

I mean, is it a common approach ?. Would it matter that new Page, would be executed each
time user clicks Next, Prev buttons ?
0
Comment
Question by:iskibinska
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Assisted Solution

by:sweetfa2
sweetfa2 earned 100 total points
ID: 34235417
A lot of pages use a similiar option to this.

A lot of pages will refresh on a list change.

The other approach is to use ajax style processing to load prev/next in the background but requires more work at the client side in particular.
0
 

Accepted Solution

by:
ilnnlm earned 150 total points
ID: 34238158
You can create the "Page" object once and store it in a session variable. Like this you will have the current page stored in the object and you can call methods like "Page->Next()", "Page->Previous()" or "Page->GoTo()".

To store the object in a session variable you will need to use the functions "serialize()" & "unserialize()" refer to the manual here http://php.net/manual/en/function.serialize.php
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 34239386
There is a canonical and definitive description of pagination here (feel free to ignore the popups, although they advertise good books):
http://articles.sitepoint.com/article/perfect-php-pagination

$_GET is one of the superglobals, so it is present in all namespaces and variable scopes.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question