graham23s Posted July 6, 2007 Share Posted July 6, 2007 Hi Guys, i'm not sure how to go about this bit, when a user gets an email on site i was after putting a checkbox besides each message so the user can check as many as they wanted at a time and delete my code as now is: <?php // get the mail .../////////////////////////////////////////////////////////////// // get the users id first...//////////////////////////////////////////////////////// $query = "SELECT * FROM `membership` WHERE `username`='$member'"; $result = mysql_query($query) or die (mysql_error()); $row = mysql_fetch_array($result) or die (mysql_error()); // the users id in avariable...//////////////////////////////////////////////////// $id = $row['id']; // now get the pms.../////////////////////////////////////////////////////////////// $query2 = "SELECT * FROM `pms` WHERE `reciever_id`='$id' ORDER BY `date_added` DESC"; $result2 = mysql_query($query2) or die (mysql_error()); // if there are no messages...////////////////////////////////////////////////////// if (mysql_num_rows($result2) == 0) { // so theres no messages in the db then...////////////////////////////////////////// echo '<br /><b>No Messages Recieved Yet. (<a href="sentbox.php">Sent Box</a>)</b><br /><br />'; include("includes/footer.php"); exit; } else { // break out of php to make some html...//////////////////////////////////////// ?> <br /> <p>My Inbox <img src="images/msg_1.gif" border="0"></p> <table width="80%" border="1" bordercolor="#000000" cellspacing="0" cellpadding="2"> <tr> <td bgcolor="#E6E6FA"><P>Subject</td> <td bgcolor="#E6E6FA"><P>From</td> <td bgcolor="#E6E6FA"><P>Date</td> <td bgcolor="#E6E6FA" ><P>Options</td> </tr> <?php } // back to the php.../////////////////////////////////////////////////////////////// // Now do a while loop to get all the results...//////////////////////////////// while ($row = mysql_fetch_array($result2)) { // define the variables...////////////////////////////////////////////////////// $id_2 = $row['id']; $read_yes_no = $row['read_flag']; $subject = $row['subject']; $sentdate = $row['date_added']; $sender_id = $row['sender_id']; if ($read_yes_no =='N') { $subject = '<strong>'.$subject.'</strong> (<font color="red"><b>NEW!</b></font>)'; } echo '<p><tr><td bgcolor="#FFFACD"><P><a href="readpm.php?id='.$id_2.'"><P>'.$subject.'</a></td>'; // get the username of the pm sender...///////////////////////////////////////// $query_3 = "SELECT id,username FROM `membership` WHERE id='$sender_id' LIMIT 1"; $result_3 = mysql_query($query_3) or die(mysql_error()); $row = mysql_fetch_array($result_3); // details in a variable as usual...//////////////////////////////////////////// $sender = $row['username']; $profile_id = $row['id']; echo '<td bgcolor="#FFFACD"><a href="user_details.php?id='.$profile_id.'"><p>'.$sender.'</a></td><P><td bgcolor="#FFFACD"><P>'.$sentdate.'</td><td bgcolor="#FFFACD"><P><a href="reply_pm.php?id='.$id_2.'&sender_id='.$sender_id.'">Reply</a> | <a href="deletepm.php?id='.$id_2.'" onclick="return confirm(\'Are You Sure You Want To Delete This Message?\');">Delete</a> | <a href="sentbox.php">Sentbox</a></tr>'; } echo "</tr></table><br /><br />"; ?> <?php // include the footer...//////////////////////////////////////////////////////////// include("includes/footer.php"); ?> any help would be appreciated Graham Link to comment https://forums.phpfreaks.com/topic/58665-solved-mass-delete-pms/ Share on other sites More sharing options...
Daniel0 Posted July 6, 2007 Share Posted July 6, 2007 Something like this? show.php: <?php $pm_result = mysql_query("SELECT * FROM `pms` WHERE `reciever_id`='$id' ORDER BY `date_added` DESC") or die(mysql_error()); if(mysql_num_rows($pm_result) > 0) { echo "<form action='mass_delete.php' method='post'>"; while($pm = mysql_fetch_assoc($pm_result)) { echo "{$pm['subject']} - <input type='checkbox' name='pm_delete[{$row['id']}]' value='1' /><br />"; } echo "<input type='submit' value='Delete selected PMs</input></form>"; } else { echo "no pms"; } ?> mass_delete.php: <?php if(is_array($_POST['pm_delete']) && count($_POST['delete'])>0) { $values = array_map('intval',$_POST['pm_delete']); if(@mysql_query("DELETE FROM pms WHERE id IN(".join(',',$values).")")) { echo "pms deleted"; } else { echo "pms could not be deleted: ".mysql_error(); } } else { die("please select some pms to delete"); } ?> Note: The code is not tested, even it it shouldn't work it should give you an idea of how to do it. Link to comment https://forums.phpfreaks.com/topic/58665-solved-mass-delete-pms/#findComment-291027 Share on other sites More sharing options...
graham23s Posted July 6, 2007 Author Share Posted July 6, 2007 Thanks Daniel thant looks good. Graham Link to comment https://forums.phpfreaks.com/topic/58665-solved-mass-delete-pms/#findComment-291108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.