How to paginate an article/news in php?

hi all,

I want to paginate an article/new, that contains more than one page of content. I don’t want to scroll down till end.

I want to check the length of the article and divide it into multiple pages and display at bottom of the page as next page links…

give me some idea about it.
Thanking you all…

Split the content across multiple pages, and place “prev page” and “next page” links along the top and bottom of the content. It’s not that difficult.

Or, are you looking for an automatic way for it to be done for you?

Something like this:


<?php

$pageNum = isset($_GET['page']) ? (int) $_GET['page'] : 0;

$self = $_SERVER['PHP_SELF'];

// get the text from the file or form mysql database 
$string = file_get_contents("D:\	est.txt");

// quantity to display 
$length = 3000;

// string length 
$string_length = strlen($string);

// page number or quantity 
$start = $pageNum * $length;

$endif = $string_length - $start;

// Returns the portion of string specified by the start and length parameters 
$msg = substr($string, $start, $length);

echo wordwrap($msg, 100, "\
");

echo "\
<br />------<br />\
";

if ($pageNum > 0)
{
    $page = $pageNum - 1;
    
    echo '<br/><a href="' . $self . '?page=' . $page . '">prev page</a>';
}

if (($string_length > $length) and ($endif > $length))
{
    $page = $pageNum + 1;
    
    echo '&nbsp;<a href="' . $self . '?page=' . $page . '">next page</a>';
}

Hi,
Thanking you for your reply…pmw57.

How to automate this functionality…?

give me an example to understand…