Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a database table? CAN U help me creating a new table in the database? So far the code has used the existing database table

Create a database table? CAN U help me creating a new table in the database?

So far the code has used the existing database table called tt284_guests, but that has no provision for a booking reference field. You will now create a new table in your database. 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 you 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. Remember that column names cannot contain spaces, so you must choose a suitable name. Once you are happy with your SQL, open table-manager.php on the TT284 server and click the create button to execute the SQL to create the table. Once a table is created it cannot be modified, so if you create a table with the incorrect structure, you must delete it before you can create a corrected version. This can be done using the drop button when executing table-manager.php.image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

38 TT284 Table manager
Share problems and solutions in the Block 2 Practical activities forum -

TT284 Block 2 - Table manager

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 E
Executing:
A
This file requires connect.php from Block 2 Part 5 resources to be uploaded to the server!
+
This file requires credentials.php from Block 2 Part 5 resources to be uploaded to the server!
+
Executing: connect.php and credentials.php -
Connected to database: e ($database name) ?>
Processing submitted form data
'; echo 'Creating table " _x ($database_table) echo '
'; ""; // So execute the SQL to create the table if ($database->query($create sql)) { echo '
'; echo 'Created table ! .x ($database_table). ""; echo '
'; } else { echo '
'; echo 'Error creating table: _x ($database->error); echo '
'; } } // Task is to drop the table... if ($task == 'drop') { echo '
'; echo 'Dropping table " _x ($database_table) ""; echo '
'; // So execute the SQL to create the table if ($database->query($drop_sql)) { echo '
'; echo 'Dropped table _x ($database table) echo '
'; } else { echo '
'; echo 'Error dropping table: : x ($database->error); echo '
'; -} // Now present the current state of the database - ?>
Reading database tables
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 query($sql); Bif (!$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 Stables[] = $row [0]; -} ?>
Reading table columns (if any)
query($sql); if (!$result) { die ("Could not execute SQL "$sql ""); } 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 // 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 Scolumns[] = $row [0]; } - } echo '

The following tables currently exist:

'; 180 181 182 echo '
    '; // Loop through each value in Stables foreach ($tables as $table) { echo '
  • ' . _x ($table) .
  • '; - } echo '
'; 183 184 185 186 187 188 189 190 ITI does NOT exist!'; "" exists with columns:'; 191 192 193 194 195 196 197 198 199 200 201 202 Bif (empty($columns)) { echo '

Table " _x ($database_table). } else { echo '

Table " x ($database table). 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). "":

'; - ?> 203

If you need to change this SQL, edit then click: ">reload the page.

I 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 LID
CREATE DROP
CAREFUL! NO UNDO!
+
- - 38 TT284 Table manager
Share problems and solutions in the Block 2 Practical activities forum -

TT284 Block 2 - Table manager

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 E
Executing:
A
This file requires connect.php from Block 2 Part 5 resources to be uploaded to the server!
+
This file requires credentials.php from Block 2 Part 5 resources to be uploaded to the server!
+
Executing: connect.php and credentials.php -
Connected to database: e ($database name) ?>
Processing submitted form data
'; echo 'Creating table " _x ($database_table) echo '
'; ""; // So execute the SQL to create the table if ($database->query($create sql)) { echo '
'; echo 'Created table ! .x ($database_table). ""; echo '
'; } else { echo '
'; echo 'Error creating table: _x ($database->error); echo '
'; } } // Task is to drop the table... if ($task == 'drop') { echo '
'; echo 'Dropping table " _x ($database_table) ""; echo '
'; // So execute the SQL to create the table if ($database->query($drop_sql)) { echo '
'; echo 'Dropped table _x ($database table) echo '
'; } else { echo '
'; echo 'Error dropping table: : x ($database->error); echo '
'; -} // Now present the current state of the database - ?>
Reading database tables
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 query($sql); Bif (!$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 Stables[] = $row [0]; -} ?>
Reading table columns (if any)
query($sql); if (!$result) { die ("Could not execute SQL "$sql ""); } 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 // 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 Scolumns[] = $row [0]; } - } echo '

The following tables currently exist:

'; 180 181 182 echo '
    '; // Loop through each value in Stables foreach ($tables as $table) { echo '
  • ' . _x ($table) .
  • '; - } echo '
'; 183 184 185 186 187 188 189 190 ITI does NOT exist!'; "" exists with columns:'; 191 192 193 194 195 196 197 198 199 200 201 202 Bif (empty($columns)) { echo '

Table " _x ($database_table). } else { echo '

Table " x ($database table). 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). "":

'; - ?> 203

If you need to change this SQL, edit then click: ">reload the page.

I 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 LID
CREATE DROP
CAREFUL! NO UNDO!
+
- -

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions