jlp09550 Posted July 30, 2007 Share Posted July 30, 2007 Hello there. I just came across a pagination script here.. but it stopped working.. I need some help. $total_pages = $post_count%10; for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href='" . $PHP_SELF . "?page=$i'>$i</a> "; } } $total_pages = 0 .. at the moment.. since $post_count divided by 10 equals 0. Thanks.. Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/ Share on other sites More sharing options...
Nakor Posted July 30, 2007 Share Posted July 30, 2007 Shouldn't it be $total_pages = ($post_count / 10); ? Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-310696 Share on other sites More sharing options...
jlp09550 Posted July 30, 2007 Author Share Posted July 30, 2007 Shouldn't it be $total_pages = ($post_count / 10); ? I had tried that.. but when the post count equals zero, it messed up the pages. Your suggestion helped a bit.. but.. like I just said.. yeah. (I had a pagination script a long time ago, but lost it.. although it worked perfectly >_<) Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-310697 Share on other sites More sharing options...
Adrianphp Posted July 30, 2007 Share Posted July 30, 2007 try $total_pages = $post_count/10; for($i = 1; $i <= $total_pages; $i++){ if($_GET['page'] == $i){ echo $i.' '; } else { echo '<a href="' . $_SERVER['PHP_SELF'] . '?page='.$i.'">'.$i.'</a> '; } } not sure if it works... i wrote it in a hurry but it should be okey Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-310732 Share on other sites More sharing options...
jlp09550 Posted July 31, 2007 Author Share Posted July 31, 2007 try $total_pages = $post_count/10; for($i = 1; $i <= $total_pages; $i++){ if($_GET['page'] == $i){ echo $i.' '; } else { echo '<a href="' . $_SERVER['PHP_SELF'] . '?page='.$i.'">'.$i.'</a> '; } } not sure if it works... i wrote it in a hurry but it should be okey Nope, doesn't help. Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-311518 Share on other sites More sharing options...
hitman6003 Posted July 31, 2007 Share Posted July 31, 2007 http://www.phpfreaks.com/tutorials/43/0.php Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-311522 Share on other sites More sharing options...
jlp09550 Posted July 31, 2007 Author Share Posted July 31, 2007 http://www.phpfreaks.com/tutorials/43/0.php I know how to make them, and I don't even understand the tutorial. I just need to have that code fixed. Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-311530 Share on other sites More sharing options...
hitman6003 Posted July 31, 2007 Share Posted July 31, 2007 $total_pages = $post_count%10; % is the modulus operator, it returns the remainder of the operation of dividing the two numbers As jlp09550 you want to use division... $total_pages = ceil($post_count / 10) < 1 ? 1 : ceil($post_count / 10); Link to comment https://forums.phpfreaks.com/topic/62428-solved-pagination-please-help/#findComment-311537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.