Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.