Jump to content

Recommended Posts

Hi, This is a private message inbox from a forum...i want so that when you check the box on a message it deletes it!

Heres the code:

[code]<?PHP
session_start();
echo "<p align=center><font size=6>Inbox</font></p>";
echo "<p align=center><a href='sendpm.php'>Send a Message</a><br><br></p>";
$username="*********";
$password="*********";
$database="*********";

$user=$_SESSION['user'];

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query2 = "SELECT * FROM Pmess Where tname='$user'";

$result2 = mysql_query($query2) or die ("Error in query: $query2. ".mysql_error());
echo "<form method='POST'>";
$t=0;
while($row = mysql_fetch_row($result2)){
echo "<table cellpadding='0' cellspacing='0' width='373' border=1><tr><td><b>By:</b> $row[2]<br><br> <b>Subject:</b> $row[3]<br><br><b>Message:</b><br> $row[4]<br><br>Delete:<input type='checkbox' name='$row[0]' value='$row[0]'></td></tr></table><br>";
$t++;
}
echo "<input type='submit' name='sub' value='Delete'></form>";
if(isset($_POST['sub'])){
//Need something!//
?>
</html>[/code]
Link to comment
https://forums.phpfreaks.com/topic/10052-deleting-variable-number-of-checkboxes/
Share on other sites

Have your checkboxes load the values (id's) into an array.

Example:
[b]<input type='checkbox' name='delete[]' value='$row[0]'/>[/b]

$_POST['delete'] will now contain an array populated with the id's of messages to be deleted.

I take it you know what to do from here. [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
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.