postheadericon PHP-Delete Record using prepared statement in PDO

Part-7: Delete Record using prepared statement in PDO.

In the last and part number seven, explain how to delete record using prepared statement. To keep delete operation simple I have not added any prompting for the confirmation of record deletion from user side.  This can be done by little bit JavaScript coding.

To delete a record first we have to select that which record we want to delete from MySQL table. Like our previous update operation we again utilize the result of search or display operation where a like delete is there to do the delete operation. When user click on that delete link the id of record is pass as a GET request to delete.php file where the actual delete statement execute of database and delete operation performed using prepared statement.


$stmt = $conn->prepare("delete from tbl where id=?");

echo "<br> Record deleted" ;
echo "<br> Problem in deleted" ;
catch(PDOException $e)
echo "Error: " . $e->getMessage();
$conn = null;

This example is divided in multiple part.

Part-1: Configure and Setup the MySQL database connection using PDO.
Part-2: Create a MySQL Database and a table using PDO.
Part-3: Insert record using prepared statement in PDO.
Part-4: Display Records using prepared statement.
Part-5: Search records using AJAX and PDO in PHP.
Part-6: Update Record using prepared statement in PDO.
Part-7: Delete Record using prepared statement in PDO.


praful said...


Unknown said...


zuan said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
web designing and development course training institute in Chennai with placement
mobile application development training course in chennai
data science course in chennai

Total Pageviews

© Powered by Blogger.