php-db | 2001071
Date: 07/12/01
- Next message: Steve Brett: "RE: [PHP-DB] Need a shopping cart"
- Previous message: a: "[PHP-DB] Hello"
- In reply to: Hugh Bothwell: "[PHP-DB] Re: Splitting Article Pages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
hello!
exactly esterday i had the same problem ;)
& i did it like this, using wordwrap/explode functions:
.......
$CFG_max_page_length = 5000;
.......
if( <email protected>($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 <email protected>> 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?
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Steve Brett: "RE: [PHP-DB] Need a shopping cart"
- Previous message: a: "[PHP-DB] Hello"
- In reply to: Hugh Bothwell: "[PHP-DB] Re: Splitting Article Pages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

