devscripts dot net tutorial

building a dynamic webpage using php, mysql and smarty

Development Scripts  Tutorials  Affiliates/Links  Contact Us  About us  Advanced Search

stage three - creating a data source and entering data

In this tutorial we will be writing a news page. In the (MySQL) database will be news articles updated by several different authors using an administration panel (not covered here).

What we are aiming to do is display todays five most recent stories on our page with the minimal amount of database interaction as we run a very busy site.

We will be making use of Smarty's caching functionality to achieve this.

To start with we will need to define the database structure.
We want to store a unique record id, the author who submitted the article, the date and time it was submitted and the article itself.
Using SQL we can create a table like this with the following code:
`title` VARCHAR( 255 ) NOT NULL ,
`author` VARCHAR( 255 ) NOT NULL ,
`date` INT NOT NULL ,
PRIMARY KEY ( `id` ) ,
) TYPE = MYISAM COMMENT = 'This table stores our News Articles';
You can use phpMyAdmin or something similar to fill in a few bogus news articles for testing!

OK so now the data is set up, we need to actually get it back out and displayed on the screen!!
next page