Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:25:20+00:00 2026-05-22T21:25:20+00:00

I have got 1 query under another one. I have got problem with the

  • 0

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.
enter image description here

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:25:21+00:00Added an answer on May 22, 2026 at 9:25 pm

    The problem is on this line:

    <input name="justcartdelete" type="hidden" value="<? echo $row1['cartjust_id']; ?>
    

    All of the ‘Sauce’ share the same input name.
    On POST, the last input name with “justcartdelete” is used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a problem with a query I'm trying to write. I have a table
I have got a table which contains 5 column and query requirements: update row
Hello I have got the problem with my query and it display the correct
I have got a native join sub query problem in MySQL Entity. SQL code
i've got a SQL query which returns multiple rows, and i have : $data
I have the following code and got myself confused: I have a query that
I have got the following problem since the server has safe mode turned on,
I have two media queries in my css (not counting the print one) :
I've got a really simple problem but I just can't sort it, fairly new
I have got a ResultSet after firing a query. Kindly let me know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.