O'Reilly logo

Sams Teach Yourself PHP in 24 Hours, Third Edition by Matt Zandstra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Data to a Table

Now that we have access to our database, we can add information to one of its tables. For the following examples, imagine that we are building a site that allows people to buy domain names.

We have created a table within the p24 database called domains. The table was created with five columns: a primary key field called id that automatically increments an integer as data is added, a domain field that contains a variable number of characters ((VARCHAR)), a sex field that contains a single character (M or F), and a mail field that contains a user’s email address. The following SQL statement was used in the MySQL client to create the table:

 create table domains ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY( id ), domain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required