More on Update Records
Learn how to modify a database record in PHP.
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,
...