I am working on ''delete functionality" in gmail inbox and i wanted to delete the selected messages .
and suppose i have marked the checkboxes (messages) i wanted to delete , then how do i GET that selected messages/checkboxes into a variable ??
here is an article that shows you exactly how to do that http://en.allexperts.com/q/PHP4-3507/Delete-checked-checkbox.htm
[php]if(is_array($_POST[‘fieldname’])) foreach($_POST[‘fieldname’] as $value){
//Do your thing
}[/php]
what if they only check one box to delete, then it would not be an array and this would not work. so you would have to add an else value = post fieldname
Well it would work just it would have 1 entry in the array.
I’m assuming this would work.
[php]if(isset($_POST[‘fieldname’])){
//delete
}[/php]
Otherwise you could try
[php]if($_POST[‘fieldname’] == 1){
//delete
}[/php]
Checked stores 1, unchecked might store 0, so if thats true try 2nd one.
As mentioned by you guys the line " if(is_set($_POST[‘fieldname’]) "…now the filed name here refers to the name of checkbox which i gave as name=“checkbox[]” in the FORM field but i am a bit confused as how to to modify the above line accordingly .
I mean should it be like is_set($_POST[‘checkbox’]) OR is_set($_POST[‘checkbox[]’]) ??
isset($_POST[‘checkbox’])
name=“checkbox”
the [] symbols after checkbox are only a signal to php that it is an array, but checkbox is the name
also I dont know if you checked out the link I sent you but I am going to post the code that was on that link so everyone who reads this will also see it without having to search around 8)
[php]
| Remove | Items | Options |
| One | Remove item | |
| Two | Remove item | |
| Three | Remove item | |
| Select/Unselect All | ||