Prior to this see : How to create and insert a row into table in PHP
This is the code for it.
<pre><?php
//connecting to host
mysql_connect("localhost", "root", "");
//Selecting a specific Database from available databases
mysql_select_db("Example");
//Deleting a rows
if(!mysql_query("delete from MyTable where slno=10"))
{
echo 'Error'.mysql_error();
}
else
{
echo 'Deleted';
}
?>
This code is used to delete a row from the table. It matches with ‘where’ and deletes a specific row. If we encounter a situation where ‘slno’ of two fields is same, then both the fields will be deleted. ‘MyTable’ is the name of the table and ‘slno’ is a field. If we want to write a condition for multiple fields we can include those fields using keyword ‘AND’. It is shown below with an example.
mysql_query("delete from MyTable where Slno=10 AND email='techdigit.in' ");
Also see: How to delete all fields in a particular table.
Share this Story






9 Comments on "Delete a row in a table in PHP"
I love your blog.Its very interesting and clear. I found you in google and Ill for sure come back to check for new fresh posts. Keep blogging like this, if more people shared this kind of great information, the net would be much better
Sup! Just wanted to write good blog. Continue with the great job youre doing!
This is a Great Blog You will probably find Exciting that people Encourage You.
I am very happy to read this. This is the kind of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this best doc.
I just couldn’t depart your site prior to suggesting that I actually enjoyed the standard info a person provide for your visitors? Is going to be back often in order to check up on new posts
This post has been extremely helpful to me. Thank you.
This article is excellent and you have accomplished a great job getting the point across with this content material. We??michael pleased along with how well you’ve got explained your current points of interest by using these intriguing, original thinking.
I need to earn a little extra money and I am a very opinionated person so I feel like writing blogs would be a good start to making some extra cash. I am a full time college student and I also have a $20 hour a week job but I am still having problems making ends meet. Thanks for any help!.
This is a right blog for anyone who desires to discover this topic. You understand a great deal its nearly difficult to argue on hand (not that I personally would want…HaHa). You certainly put a new spin using a topic thats been discussing for several years. Wonderful stuff, just excellent!