Welcome Guest, Not a member yet? Register   Sign In
Delete Multiple Rows
#1

[eluser]RedIgniter[/eluser]
How would I make a checkbox and delete button that will delete multiple rows from table, if you have list of to-do's added to your list, you want to delete multiple of them, how would I do that?
#2

[eluser]Dennis Rasmussen[/eluser]
Use an array as name for each checkbox (like name="todo[]").
The values of all the checkboxes should be the IDentifier of the row.

Then you use that array of IDs in an SQL with the WHERE IN() function.
#3

[eluser]RedIgniter[/eluser]
Could you give me an example, I got the html part but I didn't quite get the sql part
#4

[eluser]Dennis Rasmussen[/eluser]
Code:
$array = implode("','", $this->input->post('checkbox_name');
$SQL = "DELETE FROM tbl WHERE id IN ('$array')";

...
#5

[eluser]RedIgniter[/eluser]
Thank you very much, I will give it a try right now
#6

[eluser]konank[/eluser]
I was looking for this..
Thank you Very much
Smile




Theme © iAndrew 2016 - Forum software by © MyBB