CodeLobster IDE
http://codelobster.com/forum/

Problem updating multiple checkbox data to mySQL table
http://codelobster.com/forum/viewtopic.php?f=3&t=13101
Page 1 of 1

Author:  alexwaston [ Wed Aug 24, 2016 4:32 am ]
Post subject:  Problem updating multiple checkbox data to mySQL table

Hi, I'm trying to update multiple records in a MySQL table using a form with checkboxes next to rows of records. Basically the user selects (checks) the checkbox for records that they want to archive. I've tried setting it as an array but the form just isn't doing anything (no error message)

The form is as follows:

Code:
<form action="<?=Array['PHP_SELF']?>" method="post" name="archive" style="height:20px;"> 
//Then I have my code to output the rows of records from the db
<input type="hidden" value=<?php echo ; ?> name="_ID" /> //ID numbers for each record
<input type="checkbox" name="_Archived[]" value="Archived" />


Then, for when the form is submitted:
Code:
if(Array[archive])
{
   = Array["_Archived"];
    = Array["_ID"];
   echo Archiving the following...'; //This gets outputted successfully, so the form is being submitted
for ( = 0; ++;) {
     = 0;
    if (!empty(Array["_Archived"][])) {
         = 1;
        = ->query("UPDATE records SET IsArchived = 'Y' WHERE `ID` = ''"); // specify the table and field names for the SQL query
    }
}
}


Clearly it's all wrong but I can't see where, or what I need to do to update each record where the Archived checkbox has been checked... any ideas?

-----------------------------------------------------------------------------------
caroline lyrics, unsteady lyrics, starving lyrics

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/