CrazeD Posted February 11, 2008 Share Posted February 11, 2008 I'm trying to make an articles system, where you put the article in a textarea and when you view the page PHP splits it into pages. I know how to do pagination, but I'm not really sure how to go about splitting the article into pages the way I want. Just splitting into pages isn't a problem, however I'd like it to be split where specified. So far I have two ways to do that, one would be using Javascript to create multiple textarea's for each page section, and the other would be to insert, for example, {PAGE2} into the article where it would be split and have PHP parse it. For either method, I'll probably still have {PAGE2} (or whatever) entered to be parsed by PHP. The problem is, I don't really know how to parse a string and execute code if certain criteria is met. If anyone understands what I'm trying to do, can you please help in any way? Thanks. Quote Link to comment Share on other sites More sharing options...
trq Posted February 11, 2008 Share Posted February 11, 2008 Its a pretty simple concept. <?php $s = "this is page 1{newpage}this is page two{newpage}this is page three"; $pages = explode('{newpage}',$s); if (isset($_GET['page'])) { if (count($pages) <= $_GET['page']) { echo $pages[$_GET['page']-1]; } else { echo "Page does not exist"; } } else { echo $pages[0]; } echo "<a href='?page=1'>page 1</a><br />"; echo "<a href='?page=2'>page 2</a><br />"; echo "<a href='?page=3'>page 3</a><br />"; ?> Quote Link to comment Share on other sites More sharing options...
CrazeD Posted February 11, 2008 Author Share Posted February 11, 2008 Hey thanks a lot! ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.