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.
- Log into PHPMyAdmin;
- Select my database from the left-hand navigation menu, i.e. 'mestalil';
- Open the SQL panel and paste in the following SQL script:
- Test that the new table was created by selecting it from the left-hand navigation menu.
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;
The steps outlined above demonstrates how to create a new database table with 5 columns:
- contact_id - this will remain hidden from the user but will allow us to identify a particular record;
- first_name - this will be used to store a contact's first name;
- last_name - this will be used to store a contact's last name;
- phone - this will be used to store a contact's phone number; and
- email - this will be used to store a contact's e-mail address.
0 comments:
Post a Comment