Store ‘booking reference’ in the database
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
THIS QUESTION IS ABOUT .PHP PLEASE DO NOT ANSWER IN HTML! 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 ABQ-987654 Zeua Avrenim zeua.avrenim@zmail.ac.uk ACF-654321 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. save-row.php file which should be edited:
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
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY