I was wandering if anyone knew how the nextpage bbcode works, or how it is functioned, I've thought it over but I haven't really tried it, since I don't really know how to come across compiling it.
If you don't know what I'm on about, then take the tutorial publishing system on p2l for example, to make a new page for your tutorial, you use [nextpage] and it splits the tutorial into different pages, how is this done?
Thanks in advanced.
nextpage bbcode
Started by nitr0x, Aug 23 2007 03:09 PM
1 reply to this topic
#1
Posted 23 August 2007 - 03:09 PM
#2
Posted 23 August 2007 - 04:02 PM
I've written a tutorial on this once, but unfortunately the site is now dead and I can't retrieve it...
Basically just follow any normal pagination script. But, instead of using LIMIT in your MySQL query, simply select all your usual data on the tutorial from the database, and for instance if the content is in $row['content'], use explode() on it to split the content into an array, and use the index of the array correspondent to the page the user is currently on.
For example.
I'll use a dummy 'content', just for illustrative purposes.
Basically just follow any normal pagination script. But, instead of using LIMIT in your MySQL query, simply select all your usual data on the tutorial from the database, and for instance if the content is in $row['content'], use explode() on it to split the content into an array, and use the index of the array correspondent to the page the user is currently on.
For example.
I'll use a dummy 'content', just for illustrative purposes.
<?php
// MySQL connection assumed
$id = (int)$_GET['id']
$query = mysql_query('SELECT * FROM `tutorials` WHERE `tut_id` = '.$id) or die(mysql_error());
$row = mysql_fetch_array($query);
$row['content'] = 'This is a tutorial page 1![nextpage]Now we are on page two![nextpage]Nombre trois!'; // Just some dummy text so you can see what it might look like... without newlines in this example, lol
$content = explode('[nextpage]', $row['content']);
$current_page = (int)$_GET['page'];
echo $content[$current_page - 1]; // Echo tutorial content, or store in variable
?>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
