Jump to content

Delete All Messages Button


gally06

Recommended Posts

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

 

post-165167-0-42240600-1407609804_thumb.png

 

Thanks for any help in advance.

Edited by gally06
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by CroNiX
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.