How you people do the navigation in a text field.
I have a table that have records with a large text field (stored in a DB). I want to make some kind of pagination (page 1, next ->) with that field. --(in other words, i want to navigato through the textfield in ONE record)
My question is... how do you do that ??? (in the insertion). i found 2 approaches:
1. i insert many records for the same article (one record for each page) in the DB, and then i implement som kind of next_previous script. -- i dont think its the best solution
2. i insert a tag in the text field like: [Page x]. When i want to show the page i use some var in the url (or post) with the page id, and then i parse it.
any comments? how do you do that??
Navigating through A text field (page 1 page 2...)
Moderator: General Moderators
You could put a string like [--PAGEBREAK--] into the text where you want pages to break.
Next get an array of pages with:
$text = explode("[--PAGEBREAK--]", $text);
Array keys start at 0 so:
$text[0] is page 1, $text[1] is page two etc.
If you pass 0, 1, 2 etc to the script in the query string you can use that to select a page. It should be simple to create a "page 1 of 4 ... 1 | 2 | 3 | 4" type nav link to display on each page.
Also:
$total_pages = count($text); // AFTER you've exploded $text
Next get an array of pages with:
$text = explode("[--PAGEBREAK--]", $text);
Array keys start at 0 so:
$text[0] is page 1, $text[1] is page two etc.
If you pass 0, 1, 2 etc to the script in the query string you can use that to select a page. It should be simple to create a "page 1 of 4 ... 1 | 2 | 3 | 4" type nav link to display on each page.
Also:
$total_pages = count($text); // AFTER you've exploded $text