Michdd Posted November 8, 2008 Share Posted November 8, 2008 I need something that will set $start = "0", $end = "25" if $page isn't set (default) like... $page = $_REQUEST['page']; if(!isset($page)){ $page = "1"; } But then if page is set it must set things like this example: if($page == "2"){ $start = "25"; $end = "50"; } elseif($page == "3"){ $start = "50"; $end = "75 } And so on.. Quote Link to comment https://forums.phpfreaks.com/topic/131943-pagination-calculation/ Share on other sites More sharing options...
.josh Posted November 8, 2008 Share Posted November 8, 2008 Something like this? $page = $_REQUEST['page']; if(!isset($page)){ $page = "1"; } else { $start = ($page - 1) * 25; $end = $start + 25; } Quote Link to comment https://forums.phpfreaks.com/topic/131943-pagination-calculation/#findComment-685541 Share on other sites More sharing options...
Daniel0 Posted November 9, 2008 Share Posted November 9, 2008 You can do this: $page = (int) $_REQUEST['page']; $start = ($page - 1) * 25; $end = $start + 25; Quote Link to comment https://forums.phpfreaks.com/topic/131943-pagination-calculation/#findComment-685902 Share on other sites More sharing options...
Barand Posted November 9, 2008 Share Posted November 9, 2008 $page = isset($_REQUEST['page'] ? $_REQUEST['page'] : 1; $start = ($page - 1) * 25; If you are paginating with MySQL you won't need $end. Just use SELECT ........ LIMIT $start, 25 Quote Link to comment https://forums.phpfreaks.com/topic/131943-pagination-calculation/#findComment-686140 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.