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

118 Comments

  • slots online

    September 8, 2020 - 6:12 pm

    I was very happy to uncover this page. I wanted to thank you for your time for this
    fantastic read!! I definitely savored every part of it and I have
    you book marked to check out new information in your web site.

  • fun 88

    September 7, 2020 - 9:41 pm

    Paragraph writing is also a fun, if you know then you can write if not it is complex to write.

  • baccarat casino

    September 7, 2020 - 5:32 pm

    Hello there, You’ve done a great job. I’ll certainly digg it and
    personally suggest to my friends. I’m confident they’ll be benefited from
    this web site.

  • best alternatives to juul

    September 6, 2020 - 9:39 am

    Hello there, just became alert to your blog through Google, and found
    that it is truly informative. I’m going to watch out for
    brussels. I will be grateful if you continue this in future.
    Many people will be benefited from your writing.
    Cheers!

Leave A Reply