paging question

Discussion on PHP Scripting
no avatar
christina_rules
 
Posts: 3
Joined: Wed Aug 08, 2007 1:53 pm

paging question

by christina_rules » Wed Aug 08, 2007 1:59 pm

i read the tutorial "Using Paging through PHP" on this web site but there are a few things i need explanation of. i'll be grateful if any experts out there can answer some of my questions:

1. why is there a $_Get{'page'}? i saw most of the tutorials, it used $_Get['page']
2. what is 'page' in $_Get{'page'}? where did it come from?
3. why is that if i used $_PHP_SELF in <a href>, i get a notice saying that in an undefined variable?

these are the three major questions i have in mind..i really do need clarification on these three questions..please help
christina_rules

no avatar
tutorialspoint
Site Admin
 
Posts: 144
Joined: Fri Apr 27, 2007 6:52 pm

by tutorialspoint » Wed Aug 08, 2007 2:26 pm

Hi Cristina!

Your first and second questions related to $_GET{'page'}: Here is the answer


This is coming from the following setting. Here we are setting page as a part of URL and when we are clicking this URL then it is going to server and we are accessing it using $_GET{'page'}

echo "<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a> |";
echo "<a href=\"$_PHP_SELF?page=$page\">Next 10 Records</a>";


So here you can use any other name if you don't like page. Because page is more appropriate so most of the developers use page.


You third question: Not sure which variable undefined error you are getting but you need to give one variable like page to store page number so that next time you can jump to next set of pages.

We have given clear example, you are free to copy and past to use that example in your project.


Thanks
Moderator, TP
Keep visiting and share this site with your friends.

no avatar
christina_rules
 
Posts: 3
Joined: Wed Aug 08, 2007 1:53 pm

by christina_rules » Thu Aug 09, 2007 3:26 pm

thank you for your information. i appreciate it very much.

my third question was something like this: i followed your example as it is but i've encountered error message that my "$_PHP_SELF" is not defined but when i replace $_PHP_SELF with my page name the error disapppears.

so, instead of
echo "<a href=\"$_PHP_SELF?page=$last\">Last 10 Records</a> |";
i use
echo "<a href=\"mypage.php?page=$last\">Last 10 Records</a> |";

but i don't understand why i'm getting the error. do we have to set it like what we do for for example, $_Post['name']? where we have to isset() it.
christina_rules

no avatar
tutorialspoint
Site Admin
 
Posts: 144
Joined: Fri Apr 27, 2007 6:52 pm

by tutorialspoint » Thu Aug 09, 2007 4:27 pm

Hi Christina!

Please check your PHP version. This variable contains the script name since PHP 4.3.0. Previously it was not available. Because you provided script name manually so it worked.

Thanks for visiting TUTORIALSPOINT.com
Moderator, TP
Keep visiting and share this site with your friends.

Return to PHP Script