You are here: pagination « PHP Programming Language « IT news, forums, messages
pagination

Posted by Peter Parker on 06/02/07 03:07

I tried to do pagination of an article with an arbitrary 2500 characters per
page but if
the cutoff point is not the end of a paragraph (<br><br>), it would be moved
there instead. I am using php5. Here is the skeleton of my code:

$length = strlen($article);
$charsPerPage = 2500;
$numberOfPages = ceil($length/$charsPerPage);
$start = 0;

for($counter=1;counter<$numberOfPages + 1;$counter++) {
$cutOffPoint= strripos(substr($all, $start, $charsPerPage),
'<br><br>');
$pageContent = substr($article, $start, $cutOffPoint-$start);
$start = $cutOffPoint;
echo "page".counter." = ".$pageContent;
}

However, it only works for the first loop for some reason. In the
subsequent loop the $cutOffPoint is located even before the $start (visible
when I
print them out for testing purpose). Could someone show me what I am
missing?
Thanks.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация