How to Delete Data From Mysql Database

How to Delete Data From Mysql Database

In this tutorial, we will explain how to Delete Data from Mysql database which is already inserted in the database using PHP.

table.php

<?php
include(db.php);
?>
<html>
<head>
<title>Table</title>
</head>
<body>
<div class="table">
	<div class="tab1"><h1>Name</h1></div>
    <div class="tab1"><h1>Father name</h1></div>
    <div class="tab1"><h1>Mother name</h1></div>
    <div class="tab1"><h1>E-mail</h1></div>
    <div class="tab1"><h1>Address</h1></div>
    <div class="tab1"><h1>DOB</h1></div>
    <div class="tab1"><h1>Category</h1></div>
    <div class="tab1"><h1>Image</h1></div>
    <div class="tab1"><h1>Action</h1></div>
    <div class="tab1"><h1>Delete</h1></div>
    
<?php $query1 = "select * from new order by id desc limit 0,30";
$query2 = mysql_query($query1);
while($row = mysql_fetch_array($query2)) {  ?>
    
    
    <div class="tab1"><h1><?php echo $row['name'];?></h1></div>                                     
    <div class="tab1"><h1><?php echo $row['father_name'];?></h1></div>                                    <!--from database-->
    <div class="tab1"><h1><?php echo $row['mother_name'];?></h1></div>
    <div class="tab1"><h1><?php echo $row['e_mail'];?></h1></div>
    <div class="tab1"><h1><?php echo $row['address'];?></h1></div>
    <div class="tab1"><h1><?php echo $row['dob'];?></h1></div>
    <div class="tab1"><h1><?php echo $row['category'];?></h1></div>
    <div class="tab1"><h1><a href="delete.php?id=<?php //echo $row['id'];?>">Delete</a></h1></div>
    
<?php } ?>
</div>
</body>
</html>

style.css

.table{
height:400px;
width:100%;
float:left;
}

.tab1{
width:9.5%;
height:42px;
border:1px #000000 solid;
float:left;
}
.tab1 h1{
width:70px;
height:20px;
font-size:18px;
float:left;
margin:0px;
padding:0px 30px;
}
.tab1 h2{
width:89.5px;
height:20px;
font-size:18px;
float:left;
margin:0px;
padding:0px 15px;
}

delete.php

<?php 
include(db.php);
$id = $_GET['id'];
 $querydel = "delete from new where id = '$id' ";
mysql_query($querydel);
?>

db.php

<?php 
mysql_connect('localhost', 'root', '');
mysql_select_db('db');
?>

How to Fetch Data From Mysql Database using PHP

38 Comments

  1. Hey I am so excited I found your weblog, I really found
    you by error, while I was browsing on Bing for something else, Anyways I am here now and
    would just like to say thanks a lot for an incredible post and an all
    round exciting blog (I also love the theme/design), I don’t have time to go through
    it all at the moment but I have bookmarked
    it and also added in your RSS feeds, so when I have time
    I will be back to read a lot more, Please do keep up the fantastic job.

  2. I believe that is among the such a lot significant information for me.

    And I am happy to read your article. However, want to
    remark on few basic things, The web site taste is great, the articles are truly great : D.
    Just right job, cheers

  3. Hello, the whole thing is going well here and ofcourse every one is sharing facts, that’s
    really excellent, keep up writing.

  4. I was recommended this web site by means of
    my cousin. I am not positive whether or not this post is written through him as nobody
    else recognise such exact about my trouble. You are amazing!
    Thanks!

  5. I need to to thank you for this wonderful read!! I certainly enjoyed
    every little bit of it. I’ve got you bookmarked to check out
    new stuff you post…

  6. Thanks for the marvelous posting! I actually enjoyed reading it, you happen to be a great author.I will make certain to
    bookmark your blog and definitely will come back at some point.
    I want to encourage that you continue your great writing, have a nice morning!

  7. Just wish to say your article is as surprising. The clarity in your post is just spectacular and i can assume you
    are an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post.

    Thanks a million and please carry on the rewarding work.

  8. Do you mind if I quote a few of your articles
    as long as I provide credit and sources back to your blog?
    My blog is in the very same niche as yours and my users would definitely benefit from a lot of the
    information you present here. Please let me know if this ok with you.
    Many thanks!

  9. Please let me know if you’re looking for a article writer for your
    blog. You have some really good articles and I feel I would be a good asset.

    If you ever want to take some of the load off, I’d love to write some content for your blog in exchange for a
    link back to mine. Please shoot me an e-mail if interested.
    Cheers!

  10. I absolutely love your blog and find many of your post’s to be just what
    I’m looking for. Would you offer guest writers to write content for you?
    I wouldn’t mind composing a post or elaborating on a number of
    the subjects you write with regards to here. Again, awesome web site!

  11. I got this site from my friend who shared with me about this site
    and now this time I am browsing this web page and reading very informative articles at this place.

  12. whoah this blog is wonderful i like studying your posts.
    Stay up the great work! You know, lots of people are
    looking round for this info, you could help them
    greatly.

  13. Pretty section of content. I just stumbled upon your blog and in accession capital to assert that I get in fact enjoyed account your blog posts.
    Any way I will be subscribing to your augment and even I achievement you access consistently rapidly.

  14. Thanks for the marvelous posting! I actually enjoyed reading it, you happen to be a great
    author.I will be sure to bookmark your blog and will often come back down the road.
    I want to encourage continue your great posts, have a
    nice morning!

  15. Appreciating the commitment you put into your blog and in depth
    information you provide. It’s nice to come across a blog every once in a while that isn’t
    the same unwanted rehashed material. Excellent read!
    I’ve bookmarked your site and I’m including your RSS feeds to
    my Google account.

  16. Greetings from Carolina! I’m bored to tears at work so I decided to
    browse your site on my iphone during lunch break. I love the info you present here and can’t
    wait to take a look when I get home. I’m surprised at how quick your blog loaded on my
    phone .. I’m not even using WIFI, just 3G ..

    Anyhow, fantastic blog!

Comments are closed.