I have got 1 query under another one. I have got problem with the second delete query. I can not delete the right row. It always deletes the last row.
The first delete query is ok. it deletes the one i click.
here is the screen shot of the output.

When i delete burgers it works but when i press delete button for (32) Sauce it deletes the (34) Sauce
here is the code:
////////// if we submit then delete item////
if (isset($_POST['DeleteItem']))
{
echo "<h1> ID: ";
echo $_POST['cartitem_id'];
echo " deleted</h1>";
mysql_query("DELETE FROM cartitem
WHERE cartitem_id='".$_POST['cartitem_id']."'") or die(mysql_error());
}
////////// if we submit then delete justcart item in item
if (isset($_POST['DeleteCartJust']))
{
echo "<h1> ID: ";
echo $_POST['justcartdelete'];
echo " deleted</h1>";
mysql_query("DELETE FROM cartjust
WHERE cartjust_id='".$_POST['justcartdelete']."'") or die(mysql_error());
}
?>
<table width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td width="300"><u>Item</u></td>
<td align="center"><u>delete</u></td>
</tr>
<?
$result = mysql_query("SELECT * FROM cartitem WHERE ordertable_id = '$ordertable_id' ORDER BY cartitem_id ASC") or die(mysql_error());
while($row = mysql_fetch_array($result)){
?>
<form action="" method="post">
<tr>
<td>
<input name="cartitem_id" type="hidden" id="cartitem_id" value="<? echo $row['cartitem_id']; ?>" >
<? echo $row['cartitem_name']; ?>
<table>
<?
$result1 = mysql_query("SELECT * FROM cartjust WHERE cartitem_id = '".$row['cartitem_id']."' ORDER BY cartjust_id ASC") or die(mysql_error());
while($row1 = mysql_fetch_array($result1)){
?>
<tr>
<td>(<? echo $row1['cartjust_id']; ?>) <input name="justcartdelete" type="hidden" value="<? echo $row1['cartjust_id']; ?>" ></td>
<td><? echo $row1['cartjust_name']; ?></td>
<td><input type="submit" name="DeleteCartJust" value="Delete"></td>
<?
}
?>
</tr>
</table>
</td>
<td align="center" valign="top"><input type="submit" name="DeleteItem" value="Delete"></td>
</tr>
</form>
<?
}
?>
</table>
The problem is on this line:
All of the ‘Sauce’ share the same input name.
On POST, the last input name with “justcartdelete” is used.