I am trying to delete an account when the admin clicks on Delete button in the following picture:
https://www.dropbox.com/s/ytqgdgk2c581yn3/Capture.JPG
Delete.php
<?php
$con=mysqli_connect("localhost","root","123","data1");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="Delete from users where id=id";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "Record Deleted";
header("Refresh:3; url=admin.php");
mysqli_close($con);
?>
this is the code I used in the image
Admin.php
<?php
$con=mysqli_connect("localhost","root","123","data1");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM users");
echo "<table align='center' id='rounded-corner'>";
echo "<thead>
<tr>
<th scope='col' class='rounded-company'>ID</th>
<th scope='col' class='rounded-company'>Username</th>
<th scope='col' class='rounded-q1'>Password</th>
<th scope='col' class='rounded-q2'>Filter Status</th>
<th scope='col' class='rounded-q3'>Led Status</th>
<th scope='col' class='rounded-q4'>Heater Status</th>
<th scope='col' class='rounded-q4'>Edit</th>
<th scope='col' class='rounded-q4'>Delete</th>
</tr>
</thead>";
echo "<tfoot>";
echo "</tfoot>
<tbody>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['filter_st'] . "</td>";
echo "<td>" . $row['led_st'] . "</td>";
echo "<td>" . $row['heat_st'] . "</td>";
echo "<td>" . '<a class="button_green" href="edit.php">Edit</a>' . "</td>";
echo "<td>" . '<a class="button_red" href="delete.php">Delete</a>' . "</td>";
echo "</tr>";
}
echo "</tbody>
</table>";
mysqli_close($con);
?>