?
Solved

$_GET inside a PHP class

Posted on 2010-11-29
3
Medium Priority
?
661 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 400 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 600 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 111

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 count occurrences of each item in an array.
Suggested Courses

743 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