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

166 Comments

  • heliocare purewhite radiance

    November 6, 2020 - 6:39 am

    Awsome info and straight to the point. I don’t know if this is actually the
    best place to ask but do you guys have any thoughts
    on where to employ some professional writers? Thanks in advance
    🙂

  • Benedict

    October 27, 2020 - 5:43 am

    Your style is unique compared to other people I’ve read stuff from.
    Thanks for posting when you’ve got the opportunity, Guess I’ll just book mark this blog.

Leave A Reply