Nice approach.
Note that I'm not an OOP wizard, but hopefully these tips will help you and if someone disagrees, let me know.
- What version of PHP are you using? Because I've noticed that you're still using the
var.
- You
must sanitize your data ($_GET['p']) before executing a query (see below). Either use mysql_real_escape_string() or make up a regular expression to weed out all non-numbers.
- It'd be neat if you modified the class to support method chaining.
For example:
PHP Code:
$page= new pagination;
$page->connect("host","username","password","dbname");
$page->setMax(25)
->setData("tablename")
->display()
->displayLinks(5)
- I do believe that for greater flexibility, that you should perhaps accept the dots ('.....') as a parameter in your constructor.
- I'm anal about standards, but you should replace <br> with <br />
You should probably have a look at the following.
http://dalemooney.lost-soldiers.com/...imple.php?p=1-
http://dalemooney.lost-soldiers.com/...le.php?p='