Mysql databases store data in tables.
For storage of data in the database is necessary that it contains at least one created MySql table.


Create table

To create table in MySql database used PHP function mysql_query().
The table creation command requires: name of the table, names of fields and definitions for each field.
SQL query using CREATE TABLE statement, after that we will execute this SQL query through passing it to the mysqli_query() function to finally create our tableis used to create a table in MySQL.


<?php
$dbhost 
"localhost";
$dbuser "yourusername";
$dbpass  "yourpassword";
$dbname "yourdatabase";
$conn mysqli_connect($dbhost$dbuser$dbpass $dbname);
if (!
$conn) {
    die(
"Connection failed: " mysqli_connect_error());
}
$sql "CREATE TABLE members (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)"
;
if (
mysqli_query($conn$sql)) {
    echo 
"Table members created successfully";
} else {
    echo 
"Error creating table: " mysqli_error($conn);
}
mysqli_close($conn);
?>