tags:

views:

139

answers:

2

anybody help me how make a paging with php like indeed.com.

Note: 1. page view is : 1,2,3,4, .... 2. But ?start=10, ?start=20, ...

+1  A: 

The principle is as follows:

$total = 40;  // total item count
$itemsPerPage = 10;
$pages = ceil($total / $itemsPerPage);

echo '<ul>';
for ($i = 0; $i < $pages; ++$i) {
    echo '<li><a href="?start=' . ($i * $itemsPerPage) . '">' . ($i + 1) . '</a></li>';
}
echo '</ul>';
Gumbo
A: 

Decent article on how to do this in PHP and MySQL http://www.php-mysql-tutorial.com/wikis/php-tutorial/paging-using-php.aspx

micmcg
The tutorial promotes a script that is vulnerable to SQL injections. IMHO that's not so decent.
middus
Its the principle of paging, not their database connection, I was referring to
micmcg