Results 1 to 6 of 6

Thread: [RESOLVED] Deleting Private Messages...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    157

    Resolved [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).

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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($postvar01) == 'pm' &&
        (bool)
    $postval
      
    ) {
        
    // delete the PM
        // possibly, the ID would be the rest of the checkbox name?
        
    $pm_id substring($postvar2strlen($postvar));
      }

    That's vague, but you get the idea?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    157

    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.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Deleting Private Messages...

    No problems, glad you sorted it

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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
        
    }

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width