From 71a5768da1b297c807beee4e3c6a4942126c66e9 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Thu, 28 Sep 2023 16:29:16 +0530 Subject: Lab06: Creating a MySQL Database with PHP and Storing HTML Form Data --- Lab06/create_table.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Lab06/create_table.php (limited to 'Lab06/create_table.php') diff --git a/Lab06/create_table.php b/Lab06/create_table.php new file mode 100644 index 0000000..f11a89b --- /dev/null +++ b/Lab06/create_table.php @@ -0,0 +1,37 @@ +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +//Select the database +$conn->select_db($database); + +//Create table +$sql = "CREATE TABLE `$tableName` ( + id INT AUTO_INCREMENT PRIMARY KEY, + fname VARCHAR(50) NOT NULL, + lname VARCHAR(50) NOT NULL, + age INT, + gender VARCHAR(10), + phone VARCHAR(15), + email VARCHAR(100) +)"; + +if ($conn->query($sql) === TRUE) { + echo "Table created successfully"; +} else { + echo "Error creating Table: " . $conn->error; +} + +$conn->close(); +?> -- cgit v1.2.3