I am attempting to add a button to my html table that will allow a user to delete a specific row when clicked.
I have the following so far but do not understand why the corresponding database table row is not being deleted when I click the borrar (delete) button.
What part am I missing?
<?php do { ?>
<table width="263" border="1">
<tr>
<td><?php echo $row_Recordset1['name']; ?></td>
<td><form id="form1" name="form1" method="post" action="">
<input type="submit" name="borrar" id="borrar" value="Borrar" />
</form></td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<?php
if(isset($_POST['borrar'])){
if ((isset($_POST['id'])) && ($_POST['id'] != "")) {
$deleteSQL = sprintf("DELETE FROM carrito WHERE id=%s",
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_PY, $PY);
$Result1 = mysql_query($deleteSQL, $PY) or die(mysql_error());
$deleteGoTo = "http://fb.com";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
}
?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>