Do you want to limit the number of items per page, or the number of pages?
I'm guessing the first...
Then it doen't really matter what you set it to, just something that represents "not a number between 1 and max_nbr_of_pages". So, you can set it to 'all', or -1 i.e.
Then when you build your SQL LIMIT clause, check if the variable has been set to this value, and if so don't add a LIMIT clause.
PHP Code:
// make sure the limit is set and is a number $default = 3; $itemsPerPage = isset($_GET['limit'] && is_numeric($_GET['limit'])) ? $_GET['limit'] : $default;
// ... some other code ...
// build a limit clause $limit = ($itemsPerPage == -1) ? null : " LIMIT $itemsPerPage"; $query = "SELECT ... $limit";
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|