User Tag List
Results 1 to 4 of 4
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...
- Join Date
- Jan 2007
- Location
- Christchurch, New Zealand
- 14,729
- Mentioned
- 104 Post(s)
- Tagged
- 4 Thread(s)
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?Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Something like this:
PHP Code:
<?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:\test.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, "\n");
echo "\n<br />------<br />\n";
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 ' <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...
Bookmarks