Welcome Guest, Not a member yet? Register   Sign In
dealing with checkbox
#1

[eluser]basty_dread[/eluser]
How can I delete the checked items from the table to my database using codeigniter. any idea about it? Please post and help me. I am new in codeigniter. Thank you.
#2

[eluser]überfuzz[/eluser]
Do you have a single checkbox or multiple?

An example of how you can do it.
Code:
function erase()
    {
        $this->load->model('model_that_can_erase'); //make a model that erases rows in the database.
            $array = $this->input->post('erase'); //have a checkbox name="erase[]"
            foreach ($array AS $key => $value)
            {
                $this->model_that_can_erase->erase($key); //one function takes key-ids and erases the row. See to it that you get the right id to each chebox.
            }
        }
        
     }
#3

[eluser]basty_dread[/eluser]
i have many checkbox. it is on a form. usually the checkbox is created using a loop. and the data on the table is load from the database. . thank you for posting uberfuzz.
#4

[eluser]überfuzz[/eluser]
[quote author="basty_dread" date="1256393785"]i have many checkbox. it is on a form. usually the checkbox is created using a loop. and the data on the table is load from the database. . thank you for posting uberfuzz.[/quote]
Then you could use the form library in your view-file.

Code:
<?php foreach ($data_array AS $keys => $value): ?>
<p>&lt;?php echo form_radio('erase['.$keys.']','erase'); ?&gt;</p>
&lt;?php endforeach; ?&gt;

Edit, you might wanna echo the name of the checkbox.




Theme © iAndrew 2016 - Forum software by © MyBB