1. About.com
  2. Computing & Technology
  3. PHP / MySQL

Discuss in my forum

Simple Address Book

By , About.com Guide

1 of 6

The Database
Simple Address Book
This tutorial will walk you through creating a simple address book using PHP and MySQL.

Before we can begin we need to decide what fields we wish to include in our address book. For this demonstration we will use Name, E-mail and Phone number, although you can modify it to included more options if you like.

To create this database we need to execute this code:

CREATE TABLE address (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), phone VARCHAR(30), email VARCHAR(30));
INSERT INTO address (name, phone, email) VALUES ( "Alexa", "430-555-2252", "sunshine@fakeaddress.com"), ( "Devie", "658-555-5985", "potato@monkey.us" )

This creates our database fields, and puts in a couple of temporary entries for us to work with. We are creating four fields. The first is a self incrementing number, then name, phone and email. We will use the number as a unique ID for each entry when editing or deleting.

©2012 About.com. All rights reserved. 

A part of The New York Times Company.