Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Thanked 0 Times in 0 Posts

    Mark Multiple Private Message and Delete selected messages.


    I am developing private messaging system in php. everyting is done except selecting multiple (using checkbox) messages and delete them.

    below code will list messages in Inbox.
    echo "<table border='1' cellpadding='10'>";
                 echo '<tr> <th><input type="checkbox" name="selectall"></th><th>From</th> <th>Subject</th> <th>Date</th></tr>';
                       // loop through results of database query, displaying them in the table
                      while($row = mysqli_fetch_array($selectresult))
                             // echo out the contents of each row into a table
                              echo '<tr style="'.($row['message_read'] ? 'color:#BDBDBD;' : '').'">';
                              echo '<td> <input type="checkbox" name="check_list[]" value="'.$row['id'].'"> </td>';
                              echo '<td>' . $row['from_user'] . '</td>';
                              echo '<td>' . $row['message_title'] . '</td>';
                              echo '<td>' . $row['date'] . '</td>';
                              echo '<td><a href="?page_id=1427&MI=' . $row['message_id'] . '">Read</a> </td>';
                              echo '<td><a href="?page_id=1329&MI=' . $row['message_id'] . '">Delete</a> </td>';
                              echo '<td><a href="?page_id=1312&MI=' . $row['message_id'] . '">Restore</a> </td>';
                              echo "</tr>"; 
                         // close table>
                        echo "</table>";
    I want when user checked multiple checkbox and click on Delete link it should delete the selected messages.
    I am using below code for deleting inside delete page.

     foreach($_POST['check_list'] as $checkbox)
        $messageread = mysqli_query($dbc,"DELETE FROM wp_fep_messages WHERE (to_user = '$user' && to_del = '1' && id = '$checkbox')");

  2. #2
    Master Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Behind the Wall
    Thanked 567 Times in 560 Posts
    what does your query (with the data inside) looks like? what about mysqli errors?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts