PHP isset needs to be if not set
Alright, I have this:
$pg_id = isset($_GET['pg']) ? intval($_GET['pg']) : 1;
if($pg_id == -1) {
$pg_id = -1;
$pg_max = -1;
} else {
$pg_id = $pg_id - 1;
$pg_max = 12;
}
Basically this says if the "all" in paginate is clicked, to list all the items, otherwise it paginates and onl开发者_JS百科y shows a couple per page. However, I need to I guess wrap this in an if/else statement to show all to begin with.
if (!isset($_GET['pg']) || (int)$_GET['pg'] == -1) {
$pg_id = $pg_max = -1;
}
else {
$pg_id = min((int)$_GET['pg']), 1) - 1;
$pg_max = 12;
}
精彩评论