-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_table.php
45 lines (39 loc) · 1.03 KB
/
create_table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
$servername = "localhost";
$username = "owen";
$password = "mynewpassword";
$dbname = "Questionaire";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// sql to create table
$sql = "CREATE TABLE Users (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) NOT NULL,
password VARCHAR(30) NOT NULL,
permissions VARCHAR(30) NOT NULL,
reg_date TIMESTAMP
)";
if (mysqli_query($conn, $sql)) {
echo "Table Users created successfully";
} else {
echo "Error creating table: " . mysqli_error($conn);
}
// sql to create table
$sql = "CREATE TABLE Questions (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(30) NOT NULL,
question1 VARCHAR(100) NOT NULL,
question2 VARCHAR(100),
question3 VARCHAR(100)
)";
if (mysqli_query($conn, $sql)) {
echo "Table Questions created successfully";
} else {
echo "Error creating table: " . mysqli_error($conn);
}
mysqli_close($conn);
?>