MySQL uses the CREATE TABLE command to create a table.
For example, create a table users, It will have three columns: id, name and age:
CREATE TABLE Users (id INTEGER AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), age INTEGER);
Function example:
//Connect to DB $conn = mysqli_connect("localhost", "root", "password", "testdb"); //Check connection errors if (!$conn) { die("Connection error: " . mysqli_connect_error()); } //Creating table $sql = "CREATE TABLE Users (id INTEGER AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), age INTEGER);"; //Check errors if(mysqli_query($conn, $sql)){ echo "Table created"; } else{ echo "Error: " . mysqli_error($conn); } mysqli_close($conn);