CodeLobster IDE

Free cross-platform PHP IDE (HTML, PHP, CSS, JavaScript, Python code editor) with support Drupal, Joomla, Twig, JQuery, BackboneJS, LaravelJS, Node.js, CodeIgniter, CakePHP, Laravel, Magento, MeteorJS, Phalcon, Symfony, VueJS, WordPress, Yii
It is currently Thu Mar 28, 2024 2:45 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Problem updating multiple checkbox data to mySQL table
PostPosted: Wed Aug 24, 2016 4:32 am 
Offline

Joined: Thu Aug 18, 2016 7:34 am
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 49 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2016 phpBB Group