Tuesday, April 14, 2009

a simple content management system: part one

I decided to build a simple CMS to help me learn the relationship between PHP & MySQL. This first part involves creating the database table for a Contacts application that will display a list of contacts on a web page, and allow users to add, delete and edit new or existing contacts.

  1. Log into PHPMyAdmin;
  2. Select my database from the left-hand navigation menu, i.e. 'mestalil';
  3. Open the SQL panel and paste in the following SQL script:
  4. CREATE TABLE contacts (
    contact_id int(11) NOT NULL auto_increment,
    first_name varchar(50) NOT NULL default '',
    last_name varchar(50) NOT NULL default '',
    phone varchar(50) NOT NULL default '',
    email varchar(50) NOT NULL default '',
    PRIMARY KEY (contact_id)
    ) TYPE=MyISAM AUTO_INCREMENT=1;

  5. Test that the new table was created by selecting it from the left-hand navigation menu.

The steps outlined above demonstrates how to create a new database table with 5 columns:
  1. contact_id - this will remain hidden from the user but will allow us to identify a particular record;
  2. first_name - this will be used to store a contact's first name;
  3. last_name - this will be used to store a contact's last name;
  4. phone - this will be used to store a contact's phone number; and
  5. email - this will be used to store a contact's e-mail address.

0 comments:

  © 2009. Template by Ourblogtemplates.com.