Delete statement in PHP

2,426 views
2,380 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,426
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
98
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Delete statement in PHP

  1. 1. PHP Tutorials By Vineet Kumar Saini Delete Statement in PHPIn this article I will explain how to delete data in the database through HTML table. In thisarticle you will see, data deleted from the front end i.e. HTML table.Code<?php$con=mysql_connect ("localhost","root","");mysql_select_db ("mcn",$con);@$a=$_POST[txt1];@$b=$_POST[txt2];@$c=$_POST[txt3];@$d=$_POST[txt4];if(@$_POST [del]){ $s="delete from employee where name=$a";echo "Your Data Deleted"; mysql_query ($s);}$con=mysql_connect ("localhost","root","");mysql_select_db ("mcn",$con);if(@$_POST [sel]){echo $ins=mysql_query ("select * from employee");echo "<table bgcolor=skyblue border=2 align=center> <tr> <th colspan=4>Select Data From Employee Table</th></tr> <tr> <th>Nmae</th> <th>Designation</th> <th>Sal</th> <th>Qualification</th> </tr>"; while ($row=mysql_fetch_array($ins)) { echo "<tr>"; echo "<th>".$row [Name]."</th>"; echo "<th>". $row [Designation]. "</th>"; echo "<th>". $row [Sal]."</th>"; echo "<th>".$row [Qualification]."</th>"; echo "</tr>"; } } echo "</table>"?><html><head></head><body bgcolor="pink">< center>
  2. 2. PHP Tutorials By Vineet Kumar Saini<table bgcolor="skyblue" border="2">< form method="post">< tr><td colspan=2 align="center">Employee Table</td></ tr><td>Name</td><td><input type="text" name="txt1"></td></ tr><tr><td>Designation</td><td><input type="text" name="txt2"></td></ tr><tr><td>Sal</td><td><input type="text" name="txt3"></td></ tr><tr><td>Qualification</td><td><input type="text" name="txt4"></td></ tr><tr><td><input type="submit" name="del" value="Delete"></td>< td><input type="submit" name="sel" value="Select"></td></ tr></form></table></center></body></ htmlOutputFirst of all you will select data from the database using the select button. When you will clickon the select button then you will see the data table displayed on your web page. Like as inthe following image.
  3. 3. PHP Tutorials By Vineet Kumar SainiSuppose you want to delete Brajesh Kumar from your database. For this purpose you will fillin the name of the employee in the employee table, then click on the delete button. You cansee in the following image.When you will click on the delete button then display a message on your webpage i.e. "YourData Deleted".Now you will click on the select button for the selected data from the database. When youclick on the select button then display data table on your web page. In this table you willsee Brajesh kumar employee not exist. You can see in the following image.
  4. 4. PHP Tutorials By Vineet Kumar SainiConclusionSo in this article you saw how to delete data from a database in a HTML table (front end).Using this article one can easily understand how to delete data from a database.

×