TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   PHP Pagination (http://www.talkphp.com/absolute-beginners/6593-php-pagination.html)

Nahkranoth 10-29-2012 07:09 PM

PHP Pagination
 
Hello,

I need some assistance if you could give it, off course.

I have a news.php page that is part of a section of my main page that is intended to have a 3 last announcements but that i have done the split of the data already. I wanted to know how to paginate the split data in the news.php.


This is the news.php file
PHP Code:

<body>
<div id="container">
    <div id="content">
         <?php $newsHandler->displayNews();
         
         
?>
         
    </div>
    <div id="footer"></div>
</div>
</body>

I'm using the Maxnews system for the display of data and this is one of its functions in which i have added some things. this function is on another php file.
PHP Code:

function displayNews(){
        
$list $this->getNewsList();
      
//I have to get the page number here so i can make the rest of the script
        
$itemspage $pages->current_page;
        
$itemperpage 3;
        
// This counts all the files in the array
    
$filecount=$this->getNewsCount();

$currentPageList array_slice($list, ($itemspage 1) * $itemperpage$itemperpage);

echo 
"<table class='newsList'>";
foreach (
$currentPageList as $value) {
    
$newsData file($this->newsDir.DIRECTORY_SEPARATOR.$value);
    
$newsTitle  $newsData[0];
    
$submitDate $newsData[1];
    unset (
$newsData['0']);
    unset (
$newsData['1']);

    
$newsContent "";
    foreach (
$newsData as $value) {
        
$newsContent .= $value;
    }

    echo 
"<tr><th align='left'>$newsTitle</th>
    <th class='right'>
$submitDate</th></tr>";
    echo 
"<tr><td colspan='2'>".$newsContent."<br/></td></tr>";
}

echo 
"</table>";
 
 
      if (
sizeof($list) == 0){
         echo 
"<center><p>No news at the moment!</p><p>&nbsp;</p></center>";
      }


I was trying to use a paginator system but failed to do so because of some issues with the same. Righ now, i struggle at the moment on a way to get the current page, and do the rest that i think that's fine.


Could you help me?

Nahkranoth 11-02-2012 01:46 AM

Bump. i really need this. Can anyone help me?


All times are GMT. The time now is 02:11 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0