I have an equipment database. There are 972 different items in that database. Including an image url, asset number, title, description, shipping weight, etc. I have a php script that creates a table for each item. However, I don't want all 972 items to load on one page. Is there a way to use PHP to set it so that every 10 items, or tables, it creates a new page with the next 10 items, then another page, and another until it hits the last item? I have to present the site to my boss Friday. Any help would be greatly appreciated!
To do pagination with PHP/MySQL, you need to do the following:
?page=1
)To get you on the right track, your code should look something like this:
$limit = 10; // This never changes
$page = $_GET['page'];
if(!$page || !is_numeric($page) || $page < 1) {
$page = 1;
}
$offset = ($page - 1) * $limit; // Start at record 10 instead of record 0
$results = $my_db_object->getResults("SELECT * FROM equipment ORDER BY id LIMIT $limit OFFSET $offset");