How to create a database with a table
https://dev.webpages.dk/  
 
Create a Database and a Table
Create a Database and a Table:

This page will show you how you can, in PHP, create a database and a table to go with it.

On the PHP tab to the right you will see some examples on how to create a database and a table.

In the menu 'PHP & DB', you will see more examples on managing databases using PHP.

 Create a Database and a Table

How do you create a directory using PHP?

I assume that you have downloaded and installed the LAMPstack (or WAMP or MAMP), as explained in the first blogposting. Now follow these steps to setup a new database using PHP code.

The code we will use for creating the database is this:

CREATE DATABASE IF NOT EXISTS dbname;

And the code for creating the tzable is like this:

CREATE TABLE IF NOT EXISTS contacts
(
AutoID int NOT NULL AUTO_INCREMENT ,
Lastame varchar(255),
Firstname varchar(255),
EmailAddr varchar(255),
WebAddr varchar(255),
primary key(AutoID)
);


The first line will create the database for us. You can change the name of your database to what you like. With the second block we create the table, in the DB, for our contacts. In this table we will create some fields for holding info of our contacts, with firstname, lastname, emailaddress, and webaddress. These fields are set to be able to hold upto 255 characters. Also I make a field named “AutoID” that is giving each entry a number for reference. These numbers will be incrementing by 1 (one) for every new table row.

Icons made by Freepik from www.flaticon.com Create a database and a table if they don't exists
15:03:52