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 8489747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:54:50+00:00 2026-06-10T21:54:50+00:00

I’m hoping this is something small. After combing through this for a couple hours

  • 0

I’m hoping this is something small. After combing through this for a couple hours and trying all sorts of variations I’ve decided to let the pros have a crack at it.
I’ve got a page setup to administer a database easily. Basically just to update a row or delete it. For each row I’ve got a checkbox to update the row, check box to delete, three columns of info from database and then two columns with dropdown boxes to change values.
The issue is that no matter what values I choose from the dropdown, it always posts the same values. Using print_r($_POST) I can see that it’s actually returning the wrong value. Without further ado, the code:

This is at the top of my page (the form post to itself):

    if(isset($_POST['checkbox'])){
    $product = $_POST['product_choice'];
    $status = $_POST['status_choice'];
    $checkbox = $_POST['checkbox'];
    if(isset($_POST['update'])){
    $update = $_POST["update"];
    }
    $id = "('" . implode( "','", $checkbox ) . "');" ;
    $sql="UPDATE test_orders SET product='$product',status = '$status' WHERE ordNum IN $id" ;
    $result = mysql_query($sql) or die(mysql_error());
      }

And the form:

<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><form name="frmactive" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1">

<!--BUTTONS--> 

<tr>  
<td colspan="6"><input name="update" type="submit" id="update" value="Upate" />
<input name="delete" type="submit" id="delete" value="Delete" /></td>
</tr>


<tr>
<td>&nbsp;</td>
<td colspan="5"><strong>Update multiple rows in mysql with checkbox</strong> </td>
</tr>
<tr>
<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Update?</td>

<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Delete?</td>

<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Order #</td>

<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Name</td>

<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Job Name</td>

<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Product</td>

<td style="background: #ddd; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc;">Status</td>


</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>


<tr>
<td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['ordNum']; ?>"></td>
<td bgcolor="#FF0000" align="center"><input type="checkbox" name="delete[]" id="delete[]" value="<? echo $rows['ordNum']; ?>" /></td>
<td><? echo $rows['ordNum']; ?></td>
<td><? echo $rows['name']; ?></td>
<td><? echo $rows['OrderDesc']; ?></td>
<td>
<select name="product_choice" id="product" style="font-size:10px;">

            <option value="<? echo $rows['product']; ?>" selected="selected"><? echo $rows['product']; ?>
            </option>
            <option value="Color Correction"> Color Correction </option>
            <option value="Basic retouch"> Basic retouch </option>
            <option value="Extensive Retouch"> Extensive Retouch </option>
            <option value="Signature Work"> Signature Work </option>
            <option value="Signature Oil"> Signature Oil </option>
            <option value="Web Design"> Web Design </option>
            <option value="Print Design"> Print Design </option>
            <option value="Other"> Other </option>
          </select>

</td>

<td>
   <select name="status_choice" id="status" style="font-size:10px;">

            <option value="<? echo $rows['status']; ?>" selected="selected"><? echo $rows['status']; ?></option>
            <option value="Order Received"> Order Received </option>
            <option value="in the works"> in the works </option>
            <option value="waiting to upload"> waiting to upload </option>
            <option value="uploading"> uploading </option>
            <option value="ON HOLD"> ON HOLD </option>
            <option value="awaiting decision"> awaiting decision </option>
            <option value="proof sent"> proof sent </option>
            <option value="next invoice"> next invoice </option>
            <option value="waiting images/order"> waiting images/order </option>
            <option value="invoiced"> invoiced </option>
            <option value="complete"> complete </option>
            <option value="paid"> paid </option>
            <option value="making changes"> making changes </option>
          </select>

    </td>

    </tr>



<?php
}
?>
<tr>
<td colspan="6" align="center">&nbsp;</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

This is the result of print_r($_POST); no matter what options I choose in the dropdowns. the [product_choice] and [status_choice] are always the same.

Array ( [update] => Upate [checkbox] => Array ( [0] => 113 ) [product_choice] => Extensive Retouch [status_choice] => Order Received )

thanks for any help.

****SOLVED*********
Got some help from a friend, Working good is below

  • 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-06-10T21:54:52+00:00Added an answer on June 10, 2026 at 9:54 pm

    opening foreach loop:

    foreach($_POST as $key => $value) {
        if(!is_array($value)) {
            $_POST[$key] = mysql_real_escape_string($value);
        } else {
            foreach($value as $key => $value) {
                $_POST[$key][$key] = mysql_real_escape_string($value);
            }
        }
    }
    
    //print_r($_POST);
    
    // * Delete multiple via checkboxes * START *
    if(isset($_POST['delete'])) { 
        if(is_array($_POST['delete'])) {
            foreach($_POST['delete'] as $value) { 
                if(intval($value)) {
                    echo 'The order number '.$value.' has been deleted';
                    $sql_query = mysql_query("DELETE FROM $tbl_name WHERE ordNum = $value"); 
                }
            } 
        }
    } elseif(isset($_POST['checkbox'])) {
        if(isset($_POST['product_choice'])) {
            foreach($_POST['product_choice'] as $key => $value) {
                if(intval($key)) {
                    $sql_query = 'UPDATE '.$tbl_name.' SET product = "'.$_POST['product_choice'][$key].'", 
                                  status = "'.$_POST['status_choice'][$key].'" WHERE ordNum = '.$key;
                    echo $result = mysql_query($sql_query) or die(mysql_error()); 
                }
            }
        }
    }
    

    And the Dropdown boxes:

    <td>
    <?//php echo $rows['product']; ?>
    <select name="product_choice[<?php echo $rows['ordNum']?>] id="product" style="font-size:10px;">
                <option value="<?php echo $rows['product']; ?>" selected="selected"><?php echo $rows['product']; ?></option>
                <option value="Color Correction"> Color Correction </option>
                <option value="Basic retouch"> Basic retouch </option>
                <option value="Extensive Retouch"> Extensive Retouch </option>
                <option value="Signature Work"> Signature Work </option>
                <option value="Signature Oil"> Signature Oil </option>
                <option value="Web Design"> Web Design </option>
                <option value="Print Design"> Print Design </option>
                <option value="Other"> Other </option>
              </select>
    
    </td>
    
    <td>
       <select name="status_choice[<?php echo $rows['ordNum']?>] id="status" style="font-size:10px;">
    
                <option value="<?php echo $rows['status']; ?>" selected="selected"><?php echo $rows['status']; ?></option>
                <option value="Order Received"> Order Received </option>
                <option value="in the works"> in the works </option>
                <option value="waiting to upload"> waiting to upload </option>
                <option value="uploading"> uploading </option>
                <option value="ON HOLD"> ON HOLD </option>
                <option value="awaiting decision"> awaiting decision </option>
                <option value="proof sent"> proof sent </option>
                <option value="next invoice"> next invoice </option>
                <option value="waiting images/order"> waiting images/order </option>
                <option value="invoiced"> invoiced </option>
                <option value="complete"> complete </option>
                <option value="paid"> paid </option>
                <option value="making changes"> making changes </option>
              </select>
    
        </td>
    

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.