More on Update Records
Understand how to implement and manage record updates in a PHP CRUD application using MySQL. This lesson guides you through setting up the controller to capture and process project data, creating functions to fetch and update database entries securely, and handling user input effectively to maintain data integrity.
We'll cover the following...
The controller
We’ll use the same file that we used for the “Add a project” feature to implement our controller code: /controllers/project.php.
First, we’ll initialize variables to an empty string:
$project_title = $category = '';
This line of code is added just after the require statements.
We know that when the user clicks a list item from the project list, the item id is passed on to the URL. Therefore, we can capture this id with the $_GET variable in order to select the given project from the database.
if (isset($_GET['id'])) {
list($id, $project_title, ...