Jump to content

long article pagination


abeer

Recommended Posts

by googling All the tutorials I've found on pagination always refer to paginating multiple rows out of a database. Like displaying 5 rows on each page. But I'm trying to paginate an article that is being stored in one row of the table.

 

my table name is "page"

 

in the table "page" there is 4 rows

 

-------------------------------------------------------------

id | title | meta_description| meta_keywords |article

--------------------------------------------------------------

1 | title1 | meta 1| meta kewords |articles text1 bla blabla

2 | title2 | meta 2| meta kewords |articles text2 bla blabla

3 | title3 | meta 3| meta kewords |articles text3 bla blabla

4 | title4 | meta 4| meta kewords |articles text4 bla blabla

 

so in id=1 in the article text there is a article which almost 10 page size. so i need pagination for this article

 

can any one help? iam not understanding.. as i am very new in php

Link to comment
https://forums.phpfreaks.com/topic/239784-long-article-pagination/
Share on other sites

The easiest way is to make a "more page" identifier and then split the page where that is. For example:

 

Page 1
{page}
Page 2
{page}
Page 3

 

// $text contains your article

$text = explode('{page}', $text);

// $text is now an array containing each of the pages
// so do something like this:

$page = (isset($_GET['page'])) ? $_GET['page'] : 1; // if $_GET['page'] isnt set we assign $page to 1

echo $text[$page - 1]; // we minus one because array indexes start at 0 and not 1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.