xyn Posted June 30, 2007 Share Posted June 30, 2007 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 More sharing options...
Barand Posted June 30, 2007 Share Posted June 30, 2007 I'd use the 1000 chars as a start then search for the next end of paragraph (\n if it's stored as text, or < p > if stored as html. Alternatively, store them in pages from the outset Link to comment https://forums.phpfreaks.com/topic/57874-advice-needed-please/#findComment-286852 Share on other sites More sharing options...
corbin Posted June 30, 2007 Share Posted June 30, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.