TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-29-2012, 07:09 PM   #1 (permalink)
The Visitor
 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Nahkranoth is on a distinguished road
Default 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 is offline  
Reply With Quote
Old 11-02-2012, 01:46 AM   #2 (permalink)
The Visitor
 
Join Date: Oct 2012
Posts: 3
Thanks: 0
Nahkranoth is on a distinguished road
Default

Bump. i really need this. Can anyone help me?
Nahkranoth is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php & MySql Pagination Script WebSavvy Script Giveaway 40 12-22-2011 09:49 AM
PHP Beginner Guide #1 Hershey Absolute Beginners 1 11-07-2011 10:42 PM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM
what are all the subjects in php? sarmenhb General 7 01-21-2008 05:41 PM


All times are GMT. The time now is 12:20 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design