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 ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.