Specifications

create table writer_permissions (
writer varchar(16) not null, # foreign key writers.username
page varchar(16) not null # foreign key pages.code
);
drop table if exists keywords;
create table keywords (
story int not null, # foreign key stories.id
keyword varchar(32) not null,
weight int not null
);
grant select, insert, update, delete
on content.*
to content@localhost identified by ‘password’;
We need to store a little information about each writer, including a login name and password,
in the writers table. Well store their full names for displaying after each article and for greet-
ing them when they log in.
The pages table contains the page heading for each page on which stories can be displayed.
The writer_permissions table implements a many-to-many relationship indicating for which
pages a writer can submit stories.
The stories table contains separate fields for headline, story_text, and picture as dis-
cussed previously. The created, modified, and published fields are integer fields and will store
the Unix timestamp value of the relevant times.
To create the database, run the following command:
mysql –u root < create_database.sql
Implementation
Now that we have a database and image resize function to draw on, lets go about building the
main part of the system.
Front End
Lets start by looking at headlines.php, shown in Listing 26.3, which would be the first page
that a visitor to the site would see. We want to show her the headlines of the latest story from
each page.
Building Practical PHP and MySQL Projects
P
ART V
598
LISTING 26.2 Continued
32 7842 ch26 3/6/01 3:36 PM Page 598