gally06 Posted August 9, 2014 Share Posted August 9, 2014 (edited) Hey guys just wandered if you can help me on my website in the mailbox section next to the message there is a delete button to obviously delete that current message. However as I am sure you can appreciate it get tedious when you have 20 messages to do them all at once. So I am after putting a button at the top of this column in the table that will delete all the messages in there with one click. Below is the coding of where all this takes place: function mailbox($mes,$page) { global $config; if(!$page) { $page="1"; } $page=($page - 1); $totalmes=mysql_query("SELECT COUNT(*) FROM messages WHERE toid='".$_SESSION['tid']."' AND rcvddel=0"); $totalmes=mysql_result($totalmes,0); $out[body].=" <div style='float:left;width:69%;margin:5px;'> <table cellspacing='1' cellpadding='1' border='0' width='100%'> <tr> <td width='100%' class='blk_tcon' colspan='5'><b>" . LANG_MAI_MAILBOX . "</b></td> </tr> <tr> <td width='50%' colspan='2' class='blk_tcon_top'>" . LANG_MAI_SUBJECT . "</td> <td width='20%' class='blk_tcon_top'>" . LANG_MAI_FROM . "</td> <td width='25%' class='blk_tcon_top'>" . LANG_MAI_DATE . "</td> <td width='5%' class='blk_tcon_top'></td> </tr>"; $fmail=mysql_query("SELECT id,fromid,subject,active,sent FROM messages WHERE toid='".$_SESSION['tid']."' AND grid='1' AND rcvddel=0 ORDER BY sent DESC LIMIT $page, 15"); while(list($id,$fromid,$subject,$active,$sent)=mysql_fetch_row($fmail)) { $from=mysql_query("SELECT name FROM members WHERE id='$fromid'"); $from=mysql_fetch_array($from); if($fromid == '01') { $froma="Site Challenge"; }else{ $froma="<a href='./profile.php?account=$fromid'>$from[name]</a>"; } if($active == 1) { $icon="<img src='./images/unread.gif' border='0' alt='' />"; $title="<a href='./mailbox.php?action=readmail&mailtype=received&mid=$id'><b>$subject</b></a>"; }else if($active == 2){ $icon="<img src='./images/read.gif' border='0' alt='' />"; $title="<a href='./mailbox.php?action=readmail&mailtype=received&mid=$id'>$subject</a>"; }else{ $icon="<img src='./images/replied.gif' border='0' alt='' />"; $title="<a href='./mailbox.php?action=readmail&mailtype=received&mid=$id'>$subject</a>"; } $out[body].=" <tr> <td width='5%' align='center' class='blk_tcon'>$icon</td> <td width='45%' align='left' class='blk_tcon'>$title</td> <td width='20%' align='center' class='blk_tcon'>$froma</td> <td width='25%' align='center' class='blk_tcon'>$sent</td> <td width='5%' align='center' class='blk_tcon'> <form method='post'> <input type='hidden' name='mail[id]' value='$id' /> <input type='hidden' name='mail[mailtype]' value='received' /> <input type='hidden' name='action' value='delete' /> <input type='submit' class='button' name='submit' value='X' style='color:red; font-weight:bold;' title='" . LANG_MAI_DELETE . "' /> </form> </td> </tr>"; } if($totalmes == 0) { $out[body].=" <tr> <td width='100%' align='center' colspan='5' class='blk_tcon'>" . LANG_MAI_MAILBOX_EMPTY . "</td> </tr>"; } $pagenow=($page + 1); $pages=1; if($pagenow==1) { $skipranks.="[$pages] "; }else{ $skipranks.="<a href='./mailbox.php?page=1'>$pages</a> "; } $arank=1; $brank=15; while($brank < $totalmes) { $arank=($arank + 15); $brank=($brank + 15); $pages++; if($pagenow==$arank) { $skipranks.="[$pages] "; }else{ $skipranks.="<a href='./mailbox.php?page=$arank'>$pages</a> "; } } $out[body].=" <tr> <td width='100%' align='center' class='blk_tcon' colspan='5'>$skipranks</td> </tr> </table> </div> ".TOP_MENU.""; include("$config[html]"); } </tr>"; That is the whole coding of the mailbox received section, as you can see the messages section is all done in form coding so can i pop a nice button at the top to delete all or does it have to be check boxes and stuff. For help with the view of this I have attached a screenshot Thanks for any help in advance. Edited August 9, 2014 by gally06 Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 9, 2014 Share Posted August 9, 2014 Personally I'd do checkboxes, and have 2 buttons. This will allow you to delete them all, or save some. 1) Check ALL 2) Delete Selected Quote Link to comment Share on other sites More sharing options...
gally06 Posted August 9, 2014 Author Share Posted August 9, 2014 Yes it would be easier but that would mean changing the look a little which at the moment I havn't got the time so wandered if there was a way of quickly putting a button in as people are moaning they can't delete all. Is this possible? Thanks for your quick reply Quote Link to comment Share on other sites More sharing options...
CroNiX Posted August 9, 2014 Share Posted August 9, 2014 (edited) Well, sure it's possible. Probably the easiest way would be to create a form with a new submit (delete) button, and loop through the emails and create <input type="hidden" name="del[]" value="THE ID OF EACH EMAIL"> If they submit that form, $_POST['del'] will be an array of the email IDs. From there you can run a query to delete them. Edited August 9, 2014 by CroNiX Quote Link to comment Share on other sites More sharing options...
gally06 Posted August 9, 2014 Author Share Posted August 9, 2014 Thanks, much appreciated Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.