Re: Re: Splitting Article Pages
| From: | Sandis Jerics | Date: | Thu, 12 Jul 2001 11:02:34 +0000 |
| Subject: | Re: Re: Splitting Article Pages | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-10333@lists.php.net to get a copy of this message | ||
hello!
exactly esterday i had the same problem ;)
& i did it like this, using wordwrap/explode functions:
.......
$CFG_max_page_length = 5000;
.......
if(@mysql_num_rows($rez) > 0)
{
$text = nl2br(mysql_result($rez,0,"text"));
$text_length = strlen($text);
if($text_length > $CFG_max_page_length)
{
$page_count = ceil($text_length/$CFG_max_page_length);
$text = wordwrap($text, $CFG_max_page_length, "__SPLIT__", 0);
$text_arr = explode("__SPLIT__",$text);
$p = (!isset($p) || !($p>0)) ? 1 : (int)$p;
for ($page=1; $page<=$page_count; $page++)
{
$pages .= ($page != $p) ? "<a
href=$PHP_SELF?a=$a&b=$b&p=$page>$page</a> " : "<b>$page</b>
";
}
$pages = "<p align=right><b>$STR_pages:</b>
$pages</p>";
$text = $text_arr[$p-1];
}
................
echo "
$pages
<p>$text</p>
$pages";
................
http://demo.mp.lv/guru/index.php?a=1&b=17&p=1
its upcoming vortal about psyhology/metaphiscs/health in russian
which i afraid i never complete by the deadline.. :/
"Jordan Elver" <jord.elver@virgin.net> wrote
>> Hi,
>> I need to split an article over several pages. I know how to create
>> next and
>> previous links for database queries. But how can I pull out say, an
>> article
>> from a database and split the article text over a certain amount of pages
>> depending on the article length, so every 500 words and new page is
>> created?