how to create previous and next page links in php

I want to create pagination system for html files. I have created below mentioned php code:

$data = simplexml_load_file('epub_content/siddhartha3/OPS/package.opf');
$data->registerXPathNamespace('opf', '');
$itmrefcount = $data->spine[0]->itemref->count();
$itmref = $data->spine[0]->itemref[0]->attributes();
$itmrefid = $itmref['idref'];

echo 'Itemref count is : ' . $itmrefcount;

foreach ($data->spine->itemref as $itemref) {
$r = (string)$itemref->attributes()->idref;

foreach ($data->manifest->item as $item) {
$i = (string)$item->attributes()->id;
$h = (string)$item->attributes()->href;

if ($r == $i) {
//echo PHP_EOL . '<a href="epub_content/siddhartha3/OPS/' . $h . '">' . $i . '</a> ';

$url = 'epub_content/siddhartha3/OPS/' . $h;

//echo $_SESSION['curhtmlurl'];
$prm = new wlWgParam('<body>');  //the desired tag to be extracted

echo '<div id="contextract" class="well well-small" contenteditable="false">';

$wp = new wlWgProcessor(
$url, //the targeted real url
$prm, //the grabbing parameter
0     //no caching needed - it's a search engine :)


$result = $wp->get();
echo $result[0][0];
echo '</div>';




file_put_contents('epub_content/siddhartha3/OPS/package.opf', $data->saveXML());


Open in new window

Please advice how to do that?
Who is Participating?
Ray PaseurConnect With a Mentor Commented:
Where would we find the test data?
JohnLourduAuthor Commented:
Below is my test url.

My test page is behind the login page. You can register yourself using Register button. Otherwise use below user name and password.

user name : john_15071978
password: Jesus12#$

After login you can see Bookshelf. You can click any of the book except Page Blanche because it is fixed layout book, it leads to page1.php. This page is my testing page.

Basically I have creating ePub editor using simple Readium JS.
Readium JS dynamically loads ePub pages in iframe.
On click of the 'library-edit-btn', I have enable HTML5 contenteditable option to edit that html file.
On click of the 'library-save-btn', I have created dynamic form elements with values and post the form using ajax to update that html file.
All these works fine for me. Server side files are updated.
But I refresh my page, updates are gone in client side.
I guess modern browsers load dynamic iframe content from cache.
Last couple of weeks I have tried some workarounds, but those are not helpful.
So I decided to drop iframe idea. And try to pull html files in separate div elements using php.
But I need to navigate these html files using previous and next buttons.
Please advice, how to include navigation buttons with functionality in php?
Your quick response is very much appreciated.
Ray PaseurCommented:
The test URL is 404, sorry.
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

JohnLourduAuthor Commented:
Currently working for me. I have attached screenshot for your reference. Please try again once.
Jason C. LevineNo oneCommented:
Nope, 404 for me too.
JohnLourduAuthor Commented:
Sorry, there is some typo. Correct url is,
JohnLourduAuthor Commented:
I understand this should be done only using jquery and php. Not pure php. sorry for inconvenience.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.