Punjabi revolution tutorials PHP MySQL Connection Part 5 update

PHP MySQL – Updating table records using Update query.

For, update, as you know, we first need to know the existent or old values and then we modify or update those values. So we need a form with existent modifiable value and then an update button. You can recall it when you update your profile on any social media website, you are presented with old values to change them.

Here is the code from the page which has link for update link.

Line 25: The anchor link of update redirect to the page update.php with query string sending id of the table row. Since the values are sent through URL, they would be retrieved on update.php using $_GET.

Here is code of the update.php which shows the existent values.

Here after submitting the form, we are redirected to the action page for actually updating the values in database.

Line 23: is actually a hidden having id. The id would be used on next page to update the specific record.

Below is code of the update_action.php page.

It takes all the values from previous form page and update the specific row of the table using the primary key id.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *