Welcome Guest, Not a member yet? Register   Sign In
Delete a column from a database
#2

[eluser]Victor Michnowicz[/eluser]
I think you will need to use JavaScript to grab the ID of the rows that are checked. Then you can harness the amazing power of AJAX to POST all those values to a controller method that will delete those items.

View:
Code:
// In your foreach loop...
<input type="checkbox" name="item[]" value="<?php echo $row->id; ?>" />

JavaScript:
Code:
$('#delete').click(function() {

    var rows_to_delete = $('#my_table_id').serilize();

    $.post('my_controller/delete', rows_to_delete, function(data) {
        // Do some cool stuff like remove the rows
    });

});

Controller:
Code:
public function delete()
{
    $rows_to_delete = $this->input->post('item');

    // Delete them
}

I'm probably forgetting a lot of stuff, but that should get you started in a (possibly right) direction.


Messages In This Thread
Delete a column from a database - by El Forum - 02-11-2011, 04:05 PM
Delete a column from a database - by El Forum - 02-11-2011, 06:43 PM
Delete a column from a database - by El Forum - 02-12-2011, 07:09 AM
Delete a column from a database - by El Forum - 02-12-2011, 12:25 PM
Delete a column from a database - by El Forum - 02-12-2011, 12:54 PM
Delete a column from a database - by El Forum - 02-12-2011, 03:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB