Image

Imagescreamingroses wrote in Imagephp

W00T!!!!!!!!!!!!!

A while back I wrote about making a multi-page article system. I just thought I'd post the code that I came up with, in interest of open source.

In this code, we are using ### in the textarea to seperate the pages.

First, create the database (MySQL):
CREATE TABLE ArticlePages (
Id int(11) default NULL,
ArticlePage int(11) default NULL,
Content text
) TYPE=MyISAM;

CREATE TABLE Articles (
Id int(11) NOT NULL auto_increment,
Title varchar(250) default NULL,
Category text NOT NULL,
CrossBrowser text NOT NULL,
Keywords varchar(250) default NULL,
UserName varchar(100) default NULL,
UserId varchar(50) default NULL,
Author varchar(250) default NULL,
Summary text,
Sent datetime default NULL,
Views int(14) NOT NULL default '1',
Approved char(1) NOT NULL default 'N',
PRIMARY KEY (Id)
) TYPE=MyISAM;

Then, with the PHP:

if($submitarticle)
{

$sql = "insert into Articles (Title, Category, CrossBrowser, Keywords, UserName, UserId, Author, Summary, Sent)
values (\"$title\", \"$category\", \"$crossbrowser\", \"$keywords\", \"$mpage->RealName\", \"$mpage->IdNum\", \"$author\", \"$summary\", NOW())";
$svr->DoQuery($sql);
$id = mysql_insert_id();

$pages = split("###", $content);

for ($x=0; $x < sizeof($pages); $x++)
{
$pagenumber = $x + 1;
$content = $pages[$x];

$sql = "insert into ArticlePages (Id, ArticlePage, Content)
values (\"$id\", \"$pagenumber\", \"$content\")";
$svr->DoQuery($sql);
}
}

Then, remember the textarea:

< textarea name="content" cols="70" rows="30" >< /textarea >

And of course, remember to get the names correct.


I should point out that this code uses my Class, so you'll have to use your own.

-Shade