[eluser]johnmerlino[/eluser]
Thanks for response. THe problem is that even when I check the checbox, it still sends a value of 0 to the php array and hence nothing is ever updated:
Code:
form_checkbox("approved[$row->id]",$row->approved, $row->approved)
When using $this->input->post('approved'), I get this array:
Code:
array(2) { [1]=> string(1) "1" [3]=> string(1) "0" }
Notice the string "0" at the end. That should be "1" because I checked that box.
So when it's sent to update:
Code:
function update(){
$vanity_url = new VanityUrl();
$checkbox = $this->input->post('approved');
if(isset($checkbox)){
foreach($checkbox as $key => $value){
$vanity_url->where('id',$key)->get();
$vanity_url->approved = (int)$value;
$vanity_url->save();
$vanity_url->check_last_query();
}
}
}
That check_last_query function outputs this:
Code:
UPDATE `vanity_urls` SET `approved` = 1 WHERE `id` = 1
UPDATE `vanity_urls` SET `approved` = 0 WHERE `id` = 3
So despite checking the second option it still sets it to 0.
Thanks for response.