[thelist] multiple page articles on a site

Simon Willison simon at incutio.com
Thu Aug 1 14:16:01 CDT 2002


At 12:08 01/08/2002 -0700, Tom Dell'Aringa wrote:
>I've written an article I wanted to post to my site (and maybe to the
>evolt site if I can shore it up). Its not super long, but its long.
>(Hows that for relative?!). Anyway, I personally don't necessarily
>mind a really long browser page with an article. But some people do.
>
>My site is php based, and I do have a mySQL db (which I have never
>used.) Is there a "quick and dirty" way to set up a multiple page
>article? I don't have any type of CMS I can use for it right now.

It depends how quick and dirty you want to go. My solution has always been
to have a custom tag which I insert wherever a page break is required - for
example <!--pagebreak-->

You can then retrieve the entire article text from the database and do this:

$pages = explode('<!--pagebreak-->', $articleText);

$pages will then be an array of pages for your article. If $pageNumber is
the number of the page you want to display (starting at zero because we're
geeks) just use the following line to display the page:

echo $pages[$pageNumber];

You can compare the pageNumber to the number of items in the $pages array
to see if a "next page" link needs to be provided.

Hope that helps,

Simon




More information about the thelist mailing list