Jump to content

pagnation tutorial


brown2005

Recommended Posts

http://www.phpfreaks.com/tutorials/73/0.php

I need help with the above.

I can get the code to work fine and have it working, but what I want to add is

Showing: 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
Link to comment
https://forums.phpfreaks.com/topic/21651-pagnation-tutorial/
Share on other sites

  $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
Link to comment
https://forums.phpfreaks.com/topic/21651-pagnation-tutorial/#findComment-96652
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.