my if condition isn't working with the $_GET['delete'] condition. How to solve this? I'm want to delete a row from a table by reading the url. if the url contains the work delete this the mysql row should be deleted. what is the wrong i'm doing here?
<?php
$query = "SELECT * FROM category";
$select_category_id_and_title = mysqli_query($connection, $query);
while($row = mysqli_fetch_assoc($select_category_id_and_title) )
{
$cat_id = $row['id'];
$cat_title = $row['cat_title'];
echo "<tr>";
echo "<td>$cat_id</td>";
echo "<td>$cat_title</td>";
echo "<td><a href='admin_category_dashboard_new.php?delete = {$cat_id}'>DELETE</a></td>";
echo "<td><a href='admin_category_dashboard_new.php?edit = {$cat_title}'>EDIT</a></td>";
echo "</tr>";
//echo $_GET['delete'];
}
?>
<?php
if(isset($_GET['delete'])) // doesn't work
{
$delete_cat_id = $_GET['delete'];
echo '<h1>' . $delete_cat_id . '</h1>';
$query = "DELETE FROM category WHERE id = $delete_cat_id ";
$Cat_id_delete_query = mysqli_query($connection, $query);
if(!$Cat_id_delete_query)
{
die("error" . mysqli_error($connection));
}
header("Location: admin_category_dashboard_new.php ");
}
?>