How do you add Pagination to the bottom of a page?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   How do you add Pagination to the bottom of a page?
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
Does anyone know how to add pagination to the bottom of a page. Right now a page that I have in the admin control panel displays everything on one page. I want to after a certain number of lines goto a new page.

Similar to the memberlist page, and topics over a certain number of replies.



Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
If you open up the viewforum.php and look towards the bottom you will see the function pagination. It is really quite easy to implement. Give it a go and post your results.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: How do you add Pagination to the bottom of a page?
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
Code for php file:


global $prefix;

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}

require("modules/Forums/nukebb.php");
define('IN_PHPBB', true);
$phpbb_root_path = 'modules/Forums/';   
include($phpbb_root_path .'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include('includes/functions_selects.php');

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX, $nukeuser);
init_userprefs($userdata);
//
// End session management
//

   $sql = "SELECT quote_id, quote_text, quote_author, quote_status FROM $prefix"._qotm."   ORDER BY quote_id ASC ";
      if ( !($result = $db->sql_query($sql)) )
      {
         // Error if it fails...
         message_die(GENERAL_ERROR, "Couldn't obtain request list", "", __LINE__, __FILE__, $sql);
      }
       
      $quote_rows = $db->sql_fetchrowset($result);
   $quote_perpage = 10;
   $quote_total = count($quote_rows);
      $db->sql_freeresult($result);

   $page_title = 'Quote List';
   include("includes/page_header.php");

   $template->set_filenames(array(
      'body' => 'quote_list.tpl'));
   // Assign standard variables
         $template->assign_vars(array(
            'L_TEXT' => $lang['Text'],
            'L_AUTHOR' => $lang['Author'],
         ));


      for($i = 0; $i < count($quote_rows); $i++)
      {
         $template->assign_block_vars('quoterow', array( 
            'QUOTE_TEXT' =>  $quote_rows[$i]['quote_text'],
            'QUOTE_AUTHOR' =>  $quote_rows[$i]['quote_author'],
         ));
   }
         


    $template->assign_vars(array(
                'PAGINATION' => generate_pagination("quote_list.$phpEx?", $quote_total, $quote_perpage, $start),
                'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $quote_perpage) + 1 ), ceil( $quote_total / $quote_perpage )),

                'L_GOTO_PAGE' => $lang['Goto_page'])
        );


//
// Generate the page
//

$template->pparse('body');

include("includes/page_tail.php");


?>



Code for tpl file:


<table border="0" cellpadding="3" cellspacing="1" width="100%">
<td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
</table>

<table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center">
<tr>
     <th class="row4" colspan="2"><span class="cattitle">{L_QUOTE}</span></th>
</tr>

  <tr>
    <td class="row1"><table border="0" cellpadding="3" cellspacing="1" width="100%">
         <td class="row2" align="center">
         <span class="gen">
         <b>Quote Body</b>
         </span>
      </td>
      <td class="row2" align="center">         
         <span class="gen">
         <b>{L_AUTHOR}</b>
         </span>
      </td>       
         </tr>
   <!-- BEGIN quoterow -->
   <tr>
      <td class="row2" align="center">
         <span class="gen">
         {quoterow.QUOTE_TEXT}
         </span>
      </td>
      <td class="row2" align="center">
         <span class="gen">
         {quoterow.QUOTE_AUTHOR}
         </span>
      </td>
        </tr>
   <!-- END quoterow -->

</table>
</td>
</tr>
</table>
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<td align="left">{PAGE_NUMBER}</td>
<td align="right">{PAGINATION}</td>
</table>




Here is the code that I am using, my problem is that no matter what I do everything shows up on every page of the pagination. Does anyone now what I am doing wrong?

For example I have 60 items to show, and I want it to be 10 per page. All 60 items show up not matter what. The pagination shows page 1 - 6 on the bottom and I can go to each page, but all 60 show on each page.

Here is a link to how is displays. [ Register or login to view links on this board. ]


Thanks in advance.


Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
You need to order by the amount on each page.


$perpage = 10;
      if (!isset($min)) $min=0;
      if (!isset($max)) $max=$min+$perpage;
$sql = "SELECT quote_id, quote_text, quote_author, quote_status FROM $prefix"._qotm."   ORDER BY quote_id ASC LIMIT $min,$perpage";


That isnt everything you need but it will get you on the right track.



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   
JRSweets
CZ Active Member
 Codezwiz Site Donator
JRSweets has been a member for over 20 year's 20 Year Member
usa.gif massachusetts.gif
Age: 43
Gender: Male
Fav. Sports Team: NE Patriots
Website:
Status: Offline
Joined: Apr 07, 2004
0.03 posts per day
Posts: 259
Points: 19,861
  MSN Messenger 
I finally got it working. Thanks again. icon_cool.gif



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum