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.
delete.php
<?php
require("conn.php");
try
{
$stmt = $conn->prepare("delete from tbl where id=?");
$a=$stmt->execute(array($_GET["id"]));
if($a==true)
{
echo "<br> Record deleted" ;
}
else
{
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.
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Blog Archive
-
▼
2015
(13)
-
▼
July
(8)
- PHP-Delete Record using prepared statement in PDO
- PHP - Update Record using prepared statement in PDO
- PHP - Search records using AJAX and PDO
- Part-4: Display Records using prepared statement
- PHP insert update, delete using PDO part-3
- PHP insert update, delete using PDO part-2
- PHP insert update, delete using PDO part-1
- PHP PDO : insert, update delete example for beginners
-
▼
July
(8)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
3 comments:
test
Suppup
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
Post a Comment