etsted Posted February 6, 2014 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 />"; } Link to comment Share on other sites More sharing options...
thescientist Posted February 6, 2014 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 Link to comment Share on other sites More sharing options...
guruparthi Posted June 19, 2014 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now