Not logged in

Your Account

New Database Tutorial

Home/Tutorials/New Database Tutorial

New Database Tutorial

Content by: Steve Stewart

Posted a year ago with 6993 views

Creating a database

For this tutorial I've named mine "MyNewDatabase", you can call yours whatever you like.
I'm going to assume you have followed the "php mysqli Database Connect" tutorial and named you're database connection file as "dbconnection.php".
You can click on the images to view in new window...

Create a Table

We have our database, now let's add a table to it. I'm doing something simple by calling the table "siteinformation".
Do the same and call it siteinformation as later you'll see how we query for the results.

Add some information

In the first column just put id followed by ticking the box for AI (AUTO INCRIMENT) and click "GO" with PRIMARY.

Add some information continue'd

With our site information we are adding a name column, keywords and description. Notice: Name is VARCHAR 255 - Keywords is TEXT and so is Description.

Add a User to the Database

So now we are going to add a user to the database with a password, it's best to generate a password unless you want do you're own that is.
Keep you're password safe.

Add a User Privileges

Make sure that "Grand all Privileges on mynewdatabase" is showing "your" database name. The privileges for you're database to grant the user, we are going to select:
This is all you really need...

Lets add some information

For testing we are going to add some information, click on you're database and Browse.

Adding information

Click on "Insert" as we are doing this manually, as it's you're first row, id of 1 then fill in the rest.
I've added keywords with a comma, for meta tags.

Check and Generate

Oncve you've followed the steps above you're now ready to connect to you're database and display the information.
Head on over to the Check Database & Generate Code page.
Check Database & Generate Code