when i refresh will delete all records

try this code

 <?php 
$sql="SELECT * FROM administrators";
$record=mysql_query($sql);


function drop($id,$email){
$q="DELETE FROM administrators WHERE id='$id' AND email="$email"";
mysql_query($q);
header("Refresh:0");
}
if (isset($_GET['drop'])) {
  $id=$_GET['id'];$email=$_GET['email'];
drop($id,$email);
}
?>
<title>Admins Table</title>
<style>
table, th, td {
border: 2px solid black;
border-collapse: collapse;
}  
#creating {
font:bold;
font-size:1.6em;
}
</style>
<a href="https://stackoverflow.com/questions/35550971/cadmin.php"  id='creating'>Create New Admin</a><br/><br/>
<table width="920" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Number</th>
<th>First Name</th>       
<th>Last Name</th>
<th>Phone Number</th>
<th>Gender</th>
<th>Email</th>
<th>Address</th>
<th>Update</th>


   <th>Delete</th>
  </tr>
 <?php

  while($row=mysql_fetch_assoc($record)){
   echo'<tr>';
   echo'<td>'.$row['id'].'</td>';
   echo'<td>'.$row['first_name'].'</td>';
   echo'<td>'.$row['last_name'].'</td>';
   echo'<td>'.$row['phone'].'</td>';
   echo'<td>'.$row['gender'].'</td>';
   echo'<td>'.$row['email'].'</td>';
   echo'<td>'.$row['address'].'</td>';
   echo'<td>'."<a href="" onclick=''>Edit</a>".'</td>';
    echo'<td>'."<a href="?     drop=ss&id=".$row["id'].'&email=".$row["email']."'>              Drop</a>".'</td>';
 echo'</tr>';
 }

?>

Browse More Popular Posts

Leave a Comment