I'm trying to build an html table with a "remove" button on each row that once pressed, calls an sql query with the item ID as parameter, that removes an item from the "basket" table on my DB. As for now, when the button is pressed nothing happens. I think the problem should be with the parameter that I pass because when I change the query to remove specific ID when a button pressed, it does work well.
This is part of my code: (if you need the entire file I will supply the rest of the code).
html part:
<td>
<form name="myForm" method="post" action="<?php $_SERVER['PHP_SELF'];?>" >
<input type="submit" class="css3button" value="remove" / > </td>
<input type="hidden" name="Id" id="Id" value="<?php echo $Id; ?>" />
</form>
</td>
php part:
if(isset($_POST['myForm'])){
$removal = sprintf("DELETE FROM Basket WHERE Id='%s'" ,mysql_real_escape_string($Id));
$remove_result = mysql_query($removal);
if (!$remove_result ) {
echo "DB Error, could not query the database
";
echo 'MySQL Error: ' . mysql_error();
exit;
}
}