I'm trying to create a delete option for a table which is directly getting data from the mysql database. I have a function to display the table and want to add 'delete' button with each category. Somehow I get Undefined index for 'cat_id' which is 'category id'according to my table.
this is the function that i am using function dispcategories() { include ('connection.php');
$select = mysqli_query($con, "SELECT * FROM categories");
echo '';
while ($row = mysqli_fetch_assoc($select)) {
echo "<table class='category-table'>";
echo "<tr><td class='main-category' colspan='2'>".$row['category_title']."</td></tr>
<tr><td><a href='deletecategory.php?id=".$row['cat_id'].";? >'>delete</a></td></tr>;";
dispsubcategories($row['cat_id']);
echo "</table>";
}
}
and this is what i have on my delete page
$id = $_GET['cat_id'];
$del = mysqli_query($con, "DELETE FROM `categories` WHERE id='$id'");