Logo         Community
The Company
Your Account
Contact Us
Building A Quick-And-Dirty PHP/MySQL Publishing System
Looking to quickly add a dynamic news page to your corporate or personal Web site? This article shows you how.

| A Maniac Is Born |

Now, I can implement this application using a variety of different scripting languages and technologies. I can use Perl, PHP or JSP. I can store the data in a database, in an ASCII text file, or in an XML-encoded document. My personal preference here is PHP for the scripting, and a MySQL database for the data storage - first, because I find development much faster with PHP (and I also happen to like the language a great deal), and second, because the customer's existing Web site is also built on PHP and already has an active database server.

Before reading further, you should download the source code for this case study, so that you can refer to it throughout this article (you will need a Web server capable of running PHP and a mySQL database).

Download now!

Got it? Good. Now, the first thing I'm going to do is design the database tables that will hold the news information, using the information provided to me on the attributes of a press release.

Here's what I came up with:

  id smallint(5) unsigned NOT NULL auto_increment,
  slug text NOT NULL,
  content text NOT NULL,
  contact varchar(255),
  timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,

# id - unique item identifier
# slug - item title
# content - item body
# contact - contact person
# timestamp - item publication date

As you can see, this maps right into the information on the previous page - I have one field for every element of a press release.

For my initial development, I'm going to populate this table with a couple of dummy records. Here goes:

INSERT INTO news (id, slug, content, contact, timestamp) VALUES ( '1', 'Megalomaniacs Inc. Is Born', 'EARTH -- A new star was born today on the planet third closest to the sun. Megalomaniacs Inc., a venture of WeWantItAll Corp., today threw open its doors for business in the ritzy Jefferson Square business district.

Created with the sole goal of colonizing every single planet in the known Universe (and beyond), Megalomaniacs Inc. hopes to quickly acquire a monopoly over the vast tracts of uncharted real estate in space. Speaking at a press conference, Megalomaniacs Inc. CEO warned reporters that Megalomaniacs Inc. would \"take everything it could, and then some\". ', 'Peter Paul (peter@megalo.mania)', '2006-02-01 17:29:25');

INSERT INTO news (id, slug, content, contact, timestamp) VALUES ( '2', 'Megalomaniacs Inc. Expands To Mars', 'MARS -- As part of its business strategy of \"expand and swallow\", Megalomaniacs Inc. today announced that it had successfully sent a team of corporate raiders to Mars, in an effort to persuade the inhabitants of that planet to surrender their planet for colonization.

Megalomaniacs Inc. COO today said that the move was a \"friendly overture\", but that a failure to comply with the company\'s colonization plans would result in a \"swift and sure eviction of those little green guys\". ', 'Tim Jr. (tim@megalo.mania)', '2006-07-11 12:13:48');

Right. Let's get on with some code.

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
Caching Web Sites With PEAR Cache
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback