Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pagination -_-"

Featured Replies

So I've recently been studying PHP & MySQL so I could put a pagination on a website I'm working on.

I learnt the basics and used a script from over at http://papermashup.com/easy-php-pagination (which was originally written by Stranger Studios). It's not the nicest of scripts as you can see but it works... sometimes.

 

So I configured it all and it worked great on my localhost wamp server... for about 10 minutes. Now I keep receiving the "Indefined Index: Page" error on the second line in this small section:

 

$stages = 3;
$page = mysql_escape_string($_GET['page']);
if($page){
	$start = ($page - 1) * $limit; 
}else{
	$start = 0;	
	}

 

So I done some browsing and found that it does this because it empties prior to be loaded and you got to inset a if(isset) statement in there. So I placed it like this:

 

$page = mysql_escape_string(isset($_GET['page']));

 

Which is where things get strange (for me - being a PHP novice). The error disappears and my pagination becomes visible and somewhat function-able; the page links are click-able and the address bar info changes after the .php?

yet the content doesn't - whichever page I click I still receive the same content, it doesn't change at all. But when I go back into my pagination.php and remove the isset function, the pagination works perfectly even if I refresh, but the instance I change to a complete different page (outside of the page with the pagination) and come back I get the error again.

 

I've been trying to fix this for the last 6 hours and have finally given up and need some expert help :)

mysql_escape_string has been deprecated. The script is either VERY old or just an inexperienced php developer who has written it

I've actually got a php pagination class which takes all the hassle out of it (see my signature). I would recommend you use that instead or find a more up to date simple pagination script

  • Author

mysql_escape_string has been deprecated. The script is either VERY old or just an inexperienced php developer who has written it

I've actually got a php pagination class which takes all the hassle out of it (see my signature). I would recommend you use that instead or find a more up to date simple pagination script

 

Thanks for the swift reply.

However, the reason I used that script was because I'm new to PHP and trying to get used to the basics before delving into the more complex stuff like OOP. I have no idea how to use classes BUT I tried yours anyway and ended up with a page full of text (as if it echo'd your entire script) followed by a nice big error at the bottom stating "Class 'pagination' not found". I must of done something horribly wrong lol. If you know a way to fix this or the older script or a way around that ancient "mysql_escape_string" I originally posted that would be great.

 

Thanks,

Chris.

  • Author

Hi Chris

 

You probably didn't have <?php at the start of the script :)

 

Wow, can't believe I made such a noob mistake >_>

 

Anyhow, now It half works XD

I got a error at the top "Undefined variable: page_num_variable" and even though my desired results per page is working, when I click the links I get "page not found" errors; am I supposed to configure them?

 

Thanks Again.

Chris.

  • Author

Hi again!

 

Inserted the line you told me which worked great; I put a ) before the ; on the line you gave me (there were 3 open parentheses but only 2 closed). Now once again it is almost working XD. I have no errors on the main page where the pagination lies (Woot) and it is only displaying my desired number of pages along with the numeric page links.

 

The only thing that isn't working is the actual links; their are trying to send me to http://localhost/results/page/2/ which doesn't exist. My webpage in which the pagination is resided is located at http://localhost/alluziionfx/xhtml/graphics.php

 

I tried looking through the class file to see if there was somewhere I could maybe change this but I don't know a thing about classes and OOP so I didn't want to touch anything a dig myself a deeper hole.

  • Author

Are you using Jay's class?

 

Alternatively, look at the section of the code that generates your links....

 

Woot!

It is currently working; now I just need to apply styles :D

 

Thanks to both of you for the help; it's greatly appreciated!

I will be sure to study OOP when I have grasped the basics of PHP.

 

- Chris

Edited by Alluziion

Just to note, the extra ) you added at the end of your page num line, and the one just before isset are both unnecessary, it will work without. Glad you got it working :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.