I am able to get my edit button working but when i try and click the delete button it reloads the page and nothing happens.
html
<table width='80%' border=0>
<tr bgcolor='#CCCCCC'>
<td>ID</td>
<td>Voucher</td>
</tr>
<?php
$vouchlist = mysqli_query($mysqli, "SELECT * FROM vouchers");
while($resvouch = mysqli_fetch_array($vouchlist)) {
echo "<tr>";
echo "<td>".$resvouch['id']."</td>";
echo "<td>".$resvouch['voucher']."</td>";
echo "<td><a href=\"editvoucher.php?id=$resvouch[id]\">Edit</a> |
<a href=\"deletevoucher.php?id=$resvouch[id]\" onClick=\"return confirm('Are you sure you want to delete?')\">Delete</a></td>";
}
?>
</table>
deletevoucher.php
$id = $_GET['id'];
//deleting the row from table
$result = mysqli_query($mysqli, "DELETE FROM vouchers WHERE id = $id ");
header("Location:protected_page.php");
EDIT:
added this to my deletevoucher. i get this "2Data added successfully. Back to Admin Page." returned. i get the value that i click on my main php page. but it still is not deleteing...
$id = $_GET['id'];
// checking empty fields
if(empty($id) ) {
if(empty($id)) {
echo "<font color='red'>voucher id is empty.</font><br/>";
}
//link to the previous page
echo "<br/><a href='~Airways/protected_page.php'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//insert data to database
$result = mysqli_query($mysqli, "DELETE FROM vouchers WHERE (id) = ('$id') ");
//display success message
echo $id;
echo "<font color='green'>Data added successfully.";
echo "<br/><a href='protected_page.php'>Back to Admin Page.</a>";
}