From the course: PHP: Object-Oriented Programming with Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Update a record

Update a record - PHP Tutorial

From the course: PHP: Object-Oriented Programming with Databases

Start my 1-month free trial

Update a record

- [Instructor] In this movie, we're going to finish learning to update a record, using object oriented programming and our active record design pattern. So far, we've completed the first part of the update process, which is that we've retrieved a row of data from the database, and turned it into an object, so that we can present it as a form for the user, so the user can edit its properties. Now we need to do the second part, which is we need to take the values that the user submits, and we need to update a row in the database, using SQL. So here's the form that we created in the last movie, what we want now is when we click Edit Bicycle, and it submits a post_request, we want it to update the values in the database. So let's go to our code on edit.php, and you can see down here we took care of when we have a get request, that's the else down here, up here is if it's a post_request, if this form is being submitted. And you can see that we're getting all of the different values that we…

Contents