How to delete data from database using PHP and MySQLi | Part 3

In this tutorial, I will show you how to delete data from database, In previous video we saw how to insert and display data.To delete data, we must first show data, id play the main role to delete the particular row.

Steps to Delete data :

  •   Insert .php

<?php
$sel="SELECT * FROM `data`";
$sel1=mysqli_query($con,$sel);
while($result=mysqli_fetch_array($sel1))
{?>
<table>
<tr>
<td><?php echo $result['name'] ?></td>
<td><?php echo $result['class'] ?></</td>
<td><?php echo $result['marks'] ?></</td>
<td><a href="insert.php?var=<?php echo $result['id'] ?>">Delete</a></td>
<td><a href="update.php?up=<?php echo $result['id'] ?>">edit</a></td>
</tr>
</table>
<?php
}
if(isset($_GET['var']))
{
$del="DELETE FROM `data` WHERE id='".$_GET['var']."'";
mysqli_query($con,$del);  
}
?>


Rate this posting:
{[['']]}

No comments

Powered by Blogger.