Sign Up For Web Hosting
PHP & MySQL Services
No.1 CMS Host!
  • CMS-optimized servers
  • FREE CMS installation
  • FREE CMS templates
  • Free Domain name
  • Unlimited space
  • Unlimited traffic
  • Immediate activation
Buy web hosting
Sign up now Learn more
Facebook Twitter Plusone

PHP/MySQL Tutorial - Learn how to connect MySQL with PHP

Before you can do anything with your database, you should create a table and set the corresponding fields in it.

Creating a table in PHPMyAdmin is simple. Just type the name, select the number of fields and click the Go button. You will then be taken to a setup screen where you should create the fields for the database.

Alternatively, you can run a MySQL query, which will create the table. The format is:

CREATE TABLE tablename (

Fields

)

The fields are defined as follows:

fieldname type(length) extra info,

The fields are separated by comma.

For example, if you wish to create a table called Members with 3 fields in it - FirstName, LastName and Age, you should execute the following query:

CREATE TABLE Members
(
FirstName varchar(15),
LastName varchar(15),
Age int
);

More information on how to connect to the database and how to query it can be found in the following tutorials:

Step 2: Connect to the database
Step 3: Query the database
Step 4: Display table data
Step 5: Select individual records

Previous Next
(c) Copyright 2004-2012 SiteGround. All rights reserved
SiteGround is not affiliated with or endorsed by the MySQL Project or its trademark owners.