etsted 3 Posted February 6, 2014 Report Share Posted February 6, 2014 i am trying to create a pagination, but when i run this script my browser wont let me do it. Error from my browser: This webpage has a redirect loop the script: include "connect.php"; $per_page = 5; $pages_query = mysql_query("SELECT COUNT(id) FROM bruker") or die(mysql_error()); $pages = ceil(mysql_result($pages_query, 0) / $per_page); if(!isset($_GET['pages'])) { header("location: pagination.php?page=1"); } else { $page = $_GET['page']; } $start = (($page - 1) * $per_page); $bruker = mysql_query("SELECT * FROM bruker LIMIT $start, $per_page"); while($row = mysql_fetch_assoc($bruker)) { $bruker = $row['bruker']; echo $bruker . "<br />"; } Quote Link to post Share on other sites
thescientist 231 Posted February 6, 2014 Report Share Posted February 6, 2014 (edited) because that's what you're telling it to do here. you should probably change pages to page if(!isset($_GET['pages'])) { header("location: pagination.php?page=1"); Edited February 6, 2014 by thescientist Quote Link to post Share on other sites
guruparthi 1 Posted June 19, 2014 Report Share Posted June 19, 2014 You will try this to get current page value in php $page=$_GET['pages'];if($page==''){ $page=1; $start=0;}else { $start=$per_page*($page-1)} Reference: http://www.phponwebsites.com/2014/05/php-mysql-ajax-jquery-pagination.html Quote Link to post Share on other sites
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.