Hi, the following code works, however, I am looking to modify it and its not working. What I am wishing to do is insert the selected into one database, and then delete the selected from another at the same time.
Please advise if its possible. Have tried many things without success.
<?
// specify the variables in the config.php file
include("config.php");
// If the form was submitted, delete the items selected from the database
$connection = mysql_connect("$server", "$db_user", "$db_pass");
$db = mysql_select_db("$database", $connection);
if($_POST["deleted_items"] != "")
{
$delItems = implode(",", $HTTP_POST_VARS['deleted_items']);
for($x=0;$x<count($delItems);$x++)
{
$query = "DELETE FROM $table_name_sentmessages WHERE id IN ($delItems)";
$result = mysql_query($query, $connection) or die(mysql_error());
}
}
?>
<?php
$connection = mysql_connect("$server", "$db_user", "$db_pass");
$db = mysql_select_db("$database", $connection);
$query = "SELECT * FROM sentusermessages where `frommbr`='$username' order by id desc";
$result = mysql_query($query, $connection);
echo "<form action=\"sentusermessages.php\" method=\"post\"><table width=\"100%\" border=\"0\">";
echo "<tr><td><input type=\"image\" src=\"images/inbox/trash.gif\" alt=\"Delete Selected Messages\" accesskey=\"d\"></td><td><b>$lang[neworread]</b></td><td><b>To</b></td><td><b>$lang[messagedate]</b></td>
<td><b>$lang[inboxtitle]</b>
</td></tr>";
while ($rows = mysql_fetch_array($result))
{
$new = "$rows[new]";
if($new=='yes')
{
echo "<tr><td><input type=\"checkbox\" name=\"deleted_items[]\" value=\"".$rows['id']."\" title=\"Select this message for deletion: Unread message to $rows[tombr] with the title of $rows[title] which was sent on $rows[date] PST\"></td><td><img src=\"images/inbox/unopened.gif\" alt=\"Recipient has not read your message\"></td><td><a href=\"userprofile.php?user=$rows[tombr]\" accesskey=\"p\"><b>$rows[tombr]</b></a></td><td><b>$rows[date] PST</b></td><td><b><a href=\"viewsentmessage.php?id=$rows[nomer]\" accesskey=\"o\">$rows[title]</a></b></td></tr>";
}
elseif($new=='ne')
{
echo "<tr><td><input type=\"checkbox\" name=\"deleted_items[]\" value=\"".$rows['id']."\" title=\"Select this message for deletion: Read message to $rows[tombr] with the title of $rows[title] which was sent on $rows[date] PST\"></td><td><img src=\"images/inbox/opened.gif\" alt=\"Recipient has read your message\"></td><td><a href=\"userprofile.php?user=$rows[tombr]\" accesskey=\"p\"><b>$rows[tombr]</b></a></td><td>$rows[date] PST</td><td><a href=\"viewsentmessage.php?id=$rows[nomer]\" accesskey=\"o\">$rows[title]</a></td></tr>";
}
elseif($new=='deleted')
{
echo "<tr><td><input type=\"checkbox\" name=\"deleted_items[]\" value=\"".$rows['id']."\" title=\"Select this message for deletion: $rows[tombr] read and then deleted your message with the title of $rows[title] which was sent on $rows[date] PST\"></td><td><img src=\"images/inbox/deleted.gif\" alt=\"Recipient read and then deleted your message\"></td><td><a href=\"userprofile.php?user=$rows[tombr]\" accesskey=\"p\"><b>$rows[tombr]</b></a></td><td>$rows[date] PST</td><td><a href=\"viewsentmessage.php?id=$rows[nomer]\" accesskey=\"o\">$rows[title]</a></td></tr>";
}
}
?>
<?
$num_rows = mysql_num_rows($result);
if($num_rows == 0) {
echo "<tr><td colspan=\"5\" class=\"center\">There are currently no messages in your sent folder.</td></tr>";
}
?>
<?
echo "<tr><td><input type=\"image\" src=\"images/inbox/trash.gif\" alt=\"Delete Selected Messages\" accesskey=\"d\"></td><td colspan=4> </td></tr></table>";
?>