Pagination from Text data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
new2phpcode
Forum Newbie
Posts: 21
Joined: Tue Oct 09, 2007 10:40 pm

Pagination from Text data

Post by new2phpcode »

Hi guys,

Is it possible to do pagination wherein the data is coming from a text file, these data are seperated by ".:::.", my simple blog keeps on filling up the pages.....,

Code: Select all

 
$submit     = $_POST["submit"];
$title_blog = $_POST["title_blog"];
$input_blog = $_POST["input_blog"];
$date_blog  = $_POST["date_blog"];
$category_blog = $_POST["category_blog"];
$url_blog = $_POST["url_blog"];
$word_blog = $_POST["word_blog"];
$word_blog2 = $_POST["word_blog2"];
 
if (isset($_POST['submit'])) {
    $filename   = "blog.txt";
 
    $fp         = fopen( $filename,"r"); 
    $OldData    = fread($fp, 80000); 
    fclose( $fp ); 
 
    putenv("TZ=Asia/Manila");     
    $Today = date("D M j, Y g:i:s a T "); 
 
$Input = "<table width='450' border='0' align='center' cellpadding='0' cellspacing='4'><tr><td class='blogtitle'><div align='left'>
$title_blog</div></td></tr><tr><td class='textdraw'><div align='left'>$input_blog</span>$Today</div></td></tr><tr><td class='texttable'><div align='left'>category:$category_blog</div></td></tr><tr><td class='blogtitle'>&nbsp;</td></tr><tr><td class='texttable'><div align='left'><p>$word_blog</p></div></td></tr><tr><td class='texttable'><div align='left'><a href='$url_blog'>read more...</a></div></td></tr><tr><td class='commentsnotestable3'>&nbsp;</td></tr></table>.:::.";
 
    $New = "$Input$OldData";
 
    $fp = fopen( $filename,"w"); 
    if(!$fp) die("&data_blog=cannot write $filename ......&");
    fwrite($fp, $New, 800000); 
    fclose( $fp ); 
}
 
header ("location: blog.php");
 
 
 
?>
 
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Pagination from Text data

Post by jayshields »

You can paginate anything. Search around this forum for existing snippets.

On a side note, your blog mechanism seems pretty awful. Why not use some existing open source blogging tool? I'm sure you can find a flat-file solution too if you so need it.
new2phpcode
Forum Newbie
Posts: 21
Joined: Tue Oct 09, 2007 10:40 pm

Re: Pagination from Text data

Post by new2phpcode »

hahahahaha...My blog is indeed awful, many said so... Thanks for the comment... But im practicing on simple ideas.. ANyways i'll try your advise...Thank you! :D
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Pagination from Text data

Post by RobertGonzalez »

Pagination should act on your results in this case. Your results should be an array so paging through that should be a breeze.
Post Reply