Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Store booking reference in the database Modify tma02_save-row.php to add the data from the booking reference field to the database. (10 marks) Look carefully at

Store booking reference in the database

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

(10 marks)

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 ABQ-987654
Zeua Avrenim zeua.avrenim@zmail.ac.uk ACF-654321

// For security, required PHP files should "die" if SAFE_TO_RUN is not defined if (!defined('SAFE_TO_RUN')) { // Prevent this file run directly - show a warning instead die(basename(__FILE__) . ' cannot be executed directly!'); } ?>

Executing:

Saving data from $data array to row in database table

 $sql ==  

prepare($sql))) { die("Error preparing statement ($sql): $database->error"); }

// TODO: Change bind_param() calls according to the columns you expect if ($id) { // Bind parameters for UPDATE statement ('s' for each column plus 's' for id) if (!$stmt->bind_param('ssss', $data['firstname'], $data['lastname'], $data['email'], $id)) { die("Error binding statement ($sql): $stmt->error"); } } else { // Bind parameters for INSERT statement ('s' for each column) if (!$stmt->bind_param('sss', $data['firstname'], $data['lastname'], $data['email'])) { die("Error binding statement ($sql): $stmt->error"); } }

// Execute statement and count inserted/updated rows if ($stmt->execute()) { $rows = $stmt->affected_rows; } else { die("Error executing statement ($sql): $stmt->error"); }

if ($id and $rows == 0) { echo '

Server message: Row with id=' . _x($id) . ' was not changed - either it does not exist or its values did not change
'; }

if (!$id and $rows == 0) { die("No row was inserted ($sql)"); } ?>

Server message: Completed saving data to row in database table

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

Step: 3

blur-text-image

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago

Question

7. What is coaching? Is there only one type of coaching? Explain.

Answered: 1 week ago