brown2005 Posted September 22, 2006 Share Posted September 22, 2006 http://www.phpfreaks.com/tutorials/73/0.phpI need help with the above.I can get the code to work fine and have it working, but what I want to add isShowing: 1 - 10 of 34 results...i can do all of it apart from where the 10 is i can do this with the code below, but when it gets to the last page it goes 71 - 80 but should be 71 - 73 $max_results = 10; $from = (($p * $max_results) - $max_results); $page_from = $from + 1; $page_to = $page_from + 9; $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM testimonials"),0); $total_pages = ceil($total_results / $max_results); echo" <table width='695' border='0' cellspacing='0' cellpadding='0'>";echo" <tr> <td class='text_red_bold'>Showing: $page_from - $page_to of $total_results testimonials</td> </tr>";http://www.randomhomepage.co.uk/index/index.php?page=testimonials&action=view&p=8 Quote Link to comment Share on other sites More sharing options...
radalin Posted September 22, 2006 Share Posted September 22, 2006 try[code=php:0] $page_to = ( (page_from + 9) > $total_results ? $total_results : (page_from + 9) ) ;[/code]but you have to first assign total_results and then assign page_to Quote Link to comment Share on other sites More sharing options...
brown2005 Posted September 22, 2006 Author Share Posted September 22, 2006 $max_results = 10; $from = (($p * $max_results) - $max_results); $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM testimonials"),0); $total_pages = ceil($total_results / $max_results); $page_from = $from + 1; $page_to = ( (page_from + 9) > $total_results ? $total_results : (page_from + 9) ) ;hey works fine, thanks very much....oh i had to put the $ in front of page_from as u missed it Quote Link to comment 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.