Deleting a record from the database with PHP

This is a complete example of a database record delete operation with PHP, with a form that collects the data and a page that receives the data and does the deletion with PHP.

Another elementary operation that can be performed on a database is deleting a record. To do so, SQL proposes statements of the Delete type. Let’s see it with an example applied to our agenda.

It should be noted that we must first select the record to be deleted and then perform the deletion itself. To do this we will create a dynamic drop-down menu, where you can select the element you want to delete. A reference to the selected element will then be passed to a PHP page, to delete it from the database.

Delete1.php

Delete a record

Name
‘; //We create the SQL statement and execute it $sSQL=”Select name From customers Order By name”; $result=mysql_query($sSQL); echo ‘

The next step is to make the operation effective from the execution of the SQL statement that we build from the form data:

Delete2.php

Record Deleted

With this chapter we close the block of access to databases with PHP. For more related information you can refer to where you can find some other interesting article about it. Also, for those who prefer the video as teaching material, we recommend watching the .

Loading Facebook Comments ...
Loading Disqus Comments ...