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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.