Page 1 of 1

Need Help

Posted: Sun Mar 16, 2008 2:33 am
by my_everything78
Hello Everybody

Well i have a table which has a check box in every row , what i want to do is to delete more than one row at a time , now i handled the code to delete one row every time ,but i need to delete the checked row !
So how i can i do it using php ?

Thank you for your help .

Re: Need Help

Posted: Sun Mar 16, 2008 6:47 am
by Verminox
In your form, name all the checkboxes like an array, and give each one a different value. For example,

Code: Select all

<input type="checkbox" name="rows[]" value="1" /> Item 1
<input type="checkbox" name="rows[]" value="2" /> Item 2
<input type="checkbox" name="rows[]" value="3" /> Item 3
When this form is submitted to your PHP script, $_POST['rows'] will be an array of whichver values have been checked. For example, if I check only Item 1 & 3, then my $_POST['rows'] will contain an array containing '1' and '3'.

Code: Select all

var_dump($_POST['rows']);

Code: Select all

array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "3"
}