Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ia. Configure to use the new table Modify tma02_admin.php to use the new table. Only a single line of code should be changed. In your

Ia. Configure to use the new table

Modify tma02_admin.php to use the new table.

Only a single line of code should be changed.

In your solution document, provide your code.

You should perform some tests to be sure that your code is using the new table before moving on, but you do not need to provide evidence of those tests.

Ib. Store booking reference in the database

Modify tma02_save-row.php to add the data from the booking reference field to the database.

Look carefully at how the other data elements are added to the database and reflect that for the booking reference field.

Note carefully that tma02_save-row.php handles two distinct situations; one when the record has been edited and the other when the record is new. Here we are only considering a new record and you need only update that part, leaving the other unchanged.

Add the following two entries:

Table 1: Data to add to database
First name Last name Email Booking Reference
Zinolla Zanda z.zanda@zinc.ac.uk ABC-87654
Zeua Avrenim zeua.avrenim@zmail.ac.uk ACD-54321

If you have created any other records when testing, they should be removed prior to adding the two entries above. The quickest way to clear the test data is to drop and recreate the table using table-manager.php.

Table 2: Database table display
firstname lastname email
Zinolla Zanda z.zanda@zinc.ac.uk
Zeua Avrenim zeua.avrenim@zmail.ac.uk

Table 2 shows the data table which should now be displayed. Notice that the new booking reference column is not currently shown.

In your solution document, provide your code and a screenshot of the web page showing the new table containing entries with the fields completed. You can use the Show/Hide: Data from database table to produce the screenshot if required.

Ic. Display booking reference column

Modify tma02_data-table.php to display the booking reference column using data from the database.

You will need to display the booking reference column from the database in the same way the name and email columns are displayed. You are not required to add the booking reference column to the search feature, but there is no penalty for doing so.

The data table should now be as shown in Table 3 (your choice of booking reference column name may vary):

Table 3: Database table display with Booking Reference column
firstname lastname email reference
Zinolla Zanda z.zanda@zinc.ac.uk ABC-87654
Zeua Avrenim zeua.avrenim@zmail.ac.uk ACD-54321

Source code of tma02_admin.php:

image text in transcribed

Source of code tma02_save-row.php:

image text in transcribed

Source of Code tma02_data-table.php:

image text in transcribed

?php error_reporting(E_ALL); ini_set('display_errors', 1); // DO NOT MODIFY THIS LINE =[];// list of names of columns in \$task = '; // task to carry out in response to form submission // Search criteria used by search form and data table \$search = ''; // value to search for \$sorder = 'ASC'; // order to sort by // Data shown on data entry form $ data =[];// key/value data from form submission or row in database table \$valid = true; // whether data in $ data is known to be valid \$feedback =[];// key/value feedback about invalid // Define ee and x functions // Output head of page require 'tmaO2_head.php'; h1 Show/Hide: Script execution reports div class="report file" Executing: connect.php and credentials.php / div Con/div authorise viewing or whe whould also authenticate the user before we // Read the submitted form data into \$data require 'tmaO2_read-post.php'; // Read $ task and $ id (if any) from submitted form data if (!empty ($ data['task'])) \{ \$task = \$data['task'] if (!empty ($data[ id' ])){ ? == 'edit') \{ // So read the row from the database table into \$data require "tma@2_read-row.php"; // Task is to save submitted form data to a row in the database table... require "tmaO2_validate.php"; // And save the row (this will clear \$data and \$id) // Row has been saved so reset task/data/id // so that the data table is shown again and the data form is empty \$task =; \$data =[]; \$id = 3 , // Task is to delete a row from the database table... if (\$task == 'delete') { (this will clear $ id) require "tma02_delete-row.php"; // Row has been saved so reset task/data/id // so that the data table is shown again and the data form is empty \} \$task = $id= // Now we have carried out tasks, output HTML forms and tables // Output a form to search or sort with I/ This also processes search criteria used by the data table require "tmaO2_data-table.php"; // Output a form to enter or edit data (using \$data and \$id) require "tma02_data-form. php"; div class="report" Task completed! / body / html Editing File : tma02files/tma02_data-table.php div class="report" Generating a HTML table of rows in the database table $ sql = \$sql . "ORDER BY \$sort \$order"; =%. \$search . '\%'; // Bind parameters for SELECT statement ('s' for each column, \$term for each column) die("Error binding statement (\$sql): \$stmt->error"); // Execute statement and get result \$f (\$stmt->execute()) \{ \} die("Error executing statement (\$sql): \$stmt->error"); if (!\$result) \{ \} die("Error obtaining result (\$sql) : \$stmt->error"); I/ If there is no task, or if searching, show the table by default \$checked = 'checked' else \{ ?) input ?php_e(\$checked) ?> id="show_table" type="checkbox" class="collapser" > Show/Hide: Data from / label> table thead ! Read each row as an array indexed by column names .. pphp while (\$row = \$result->fetch_assoc ()){ ? ! TODO: Change table data to output the columns you expect td ?php e($ row, 'firstname') ?/ td td ?php _e(\$row, 'lastname') ?/td td ?php _e(\$row, 'email') ?/td form method="POST" action="?php ee(\$url); ?>" / form ttd / form ?php } tr / tbody / tbody tfoot tr !- This table has 3 columns but the last row has only 2 cells, (td colspan="2"> ?php_e(\$result->num_rows) ?> results ?php if (\$search) { ?> for "" /td

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

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

How can management accountants help formulate strategy?

Answered: 1 week ago

Question

Explain how to make a to-do list and a schedule.

Answered: 1 week ago