Jump to content

Advice needed please?


xyn

Recommended Posts

Hi.

Thanks for considering to help me, although my problem is.

I have a website to store specific Tutorials. basically using

MySQL. some tutorials may be longer than others.

 

Now I was wondering if there was a way to automatically

paginate tutorials by a set amount of characters?

say 1000 characters.

 

Or is there any other methods you guys could advise me to do?

 

Thanks,

I really appreciate anything you can do to help me!

Link to comment
https://forums.phpfreaks.com/topic/57874-advice-needed-please/
Share on other sites

To add onto Barand's response, I suggest splitting the tutorials into pages before you store them in the database.

 

That way you don't have to pull the entire thing and trim it every time a page is loaded.  You could just load the specific page you wanted.

 

Forexample:

 

if(is_numeric($_GET['tutorial_id'])) {
$page = (is_numeric($_GET['page'])) ? $_GET['page'] : 1;
$tid = $_GET['tutorial_id'];
$q = "SELECT content FROM tutorials WHERE page='1' AND tutorial_id = '{$tid}'";
$q = mysql_query($q);
if(mysql_num_rows($q) > 0) {
$r = mysql_fetch_array($q);
echo $r['content'];
}
else {
echo 'Incorrect page or tutorial.';
}
}
else echo 'Incorrect tutorial.';

Link to comment
https://forums.phpfreaks.com/topic/57874-advice-needed-please/#findComment-286878
Share on other sites

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.