Question
Q1, Create a database table Modify table-manager.php Hint : Examine the file table-manager.php Notice the variable $database_table which must be set to the name of
Q1, Create a database table Modify table-manager.php Hint : Examine the file table-manager.php
Notice the variable $database_table which must be set to the name of your new table required. You will create a table called tt284_oucu. (Where 'oucu' is replaced with your own OUCU).
Your new table will contain all the columns which exist in tt284_guests, with the addition of the new booking reference column. Base your answer closely on the existing SQL statement.
The booking reference field may contain up to 10 characters.
Modify the SQL statement in the $create_sql variable to meet these requirements.
Source code : table-manager.php
// Allow debugging error_reporting(E_ALL); ini_set('display_errors', 1);
// Define a constant to permit each file we "require" to execute // For security, required PHP files should "die" if SAFE_TO_RUN is not defined define('SAFE_TO_RUN', true);
// TODO: Change this value to configure the application $database_table = "tt284_guests"; // name of database table to create/drop
// SQL to create table with appropriate fields // TODO: Change these columns to meet application requirements // There must be a column between each field BUT no comma after the last field $create_sql = "CREATE TABLE $database_table ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50) NOT NULL )";
// SQL to delete table $drop_sql = "DROP TABLE $database_table";
// Setup variables used in the application $url = $_SERVER["PHP_SELF"]; // URL of this page for forms to POST to $tables = []; // list of names of tables in database $columns = []; // list of names of columns in database table (if it exists) $task = ''; // task to carry out in response to form submission
// Define _e and _x functions require 'helpers.php'; ?>
zu110279 - Erehwon Guest House
// Task is to create the table... if ($task == 'create') { echo '
// So execute the SQL to create the table if ($database->query($create_sql)) { echo '
// Task is to drop the table... if ($task == 'drop') { echo '
// So execute the SQL to drop the table if ($database->query($drop_sql)) { echo '
// Now present the current state of the database ?>
query($sql);
if (!$result) { die("Could not execute SQL \"$sql\""); }
// Read each row as an array indexed by numbers while ($row = $result->fetch_row()) { // Put the first item in each row into the tables array $tables[] = $row[0]; } ?>
query($sql);
if (!$result) { die("Could not execute SQL \"$sql\""); }
// Read each row as an array indexed by numbers while ($row = $result->fetch_row()) { // Put the first item in each row into the columns array $columns[] = $row[0]; } }
echo '
The following tables currently exist:
';echo '
- '; // Loop through each value in $tables foreach ($tables as $table) { echo '
- ' . _x($table) . ' '; } echo '
if (empty($columns)) { echo '
Table "' . _x($database_table) . '" does NOT exist!
'; } else { echo 'Table "' . _x($database_table) . '" exists with columns:
'; echo '- '; // Loop through each value in $columns foreach ($columns as $column) { echo '
- ' . _x($column) . ' '; } echo '
// Finally present a form with buttons to execute the SQL echo '
Create or drop "' . _x($database_table) . '":
'; ?>If you need to change this SQL, edit then click: ">reload the page.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started