Code has been added to clipboard!
Generating Tables With MySQL
Example
<?php
$host = 'host';
$user = 'user';
$pass = 'pass';
$db = 'db';
// Create connection
$conn = new mysqli($host, $user, $pass, $db);
// Check connection
if ($conn->connect_error)Â { Â Â Â
die("Failed to connect: " . $conn->connect_error);
}
// sql to create table
$sql = "CREATE TABLE users (user_id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(40) NOT NULL,password VARCHAR(40) NOT NULL,email VARCHAR(60),register_date TIMESTAMP)";
if ($conn->query($sql) === TRUE) {Â Â Â
echo "users table created.";
} else {
echo "Failed to create table: " . $conn->error;
}
$conn->close();
?>