|
-
Mar 31st, 2006, 03:51 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Deleting Private Messages...
Alright.. I am making a website, an I made a custom private messaging system, thing is.. I cannot seem to figure out how to delete multiple PMs at once.. Could someone explain to me how this is done? (I am using a check-box to select the wanted pms that are going to be deleted).
-
Mar 31st, 2006, 10:22 PM
#2
Re: Deleting Private Messages...
Up to you.
Each check box would be one POST/GET parameter (POST would be the proper method) so you'd need to loop through POST paremeters I suppose.
PHP Code:
foreach($_POST as $postvar => $postval) {
// some way of identifying it as a checkbox var
if (
substring($postvar, 0, 1) == 'pm' &&
(bool)$postval
) {
// delete the PM
// possibly, the ID would be the rest of the checkbox name?
$pm_id = substring($postvar, 2, strlen($postvar));
}
}
That's vague, but you get the idea?
-
Apr 1st, 2006, 12:02 AM
#3
Thread Starter
Addicted Member
Re: Deleting Private Messages...
$_POST = the word 'Array'.. When I try to "array($_POST)" it still returns array.. Any idea as to how I can get this working? 
Edit:
Sorry, I didn't read your post right. It works correctly, thanks.
Last edited by Jaquio; Apr 1st, 2006 at 12:11 AM.
Reason: Didn't read it right.
-
Apr 1st, 2006, 01:41 AM
#4
Re: [RESOLVED] Deleting Private Messages...
No problems, glad you sorted it
-
Apr 1st, 2006, 03:12 AM
#5
Re: [RESOLVED] Deleting Private Messages...
I usually construct the list as follows in html. Assuming each PM has an ID:
HTML Code:
PM 1 <input type="checkbox" name="delete[]" value="1" />
PM 2 <input type="checkbox" name="delete[]" value="2" />
PM 3 <input type="checkbox" name="delete[]" value="3" />
PM 4 <input type="checkbox" name="delete[]" value="4" />
Beucase you called it delete[], PHP will automatically construct an array containing the values of the numbers selected:
PHP Code:
if(isset($_POST['delete']) && is_array($_POST['delete'])) {
foreach($_POST['delete'] as $pmId) {
$pmId = (int) $pmId; // samitise appropriatly
// delete PM
}
}
-
Apr 1st, 2006, 03:30 AM
#6
Re: [RESOLVED] Deleting Private Messages...
Sweet, that's way better than my method
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|