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
Solved

$_GET inside a PHP class

Posted on 2010-11-29
3
653 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
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 109

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

861 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