every time i try to check and delete a msg it always shows 0 msg successfully deleted. i dont know where is my error here. here is my code:
PHP Code:
echo "<head>";
echo "<title>My Messages</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$test[0]\"/>";
echo "</head>";
echo "<meta http-equiv=\"refresh\" content=\"20; URL= inbox.php?do=$do&rid=$rid\"/>";
addonline(getuid_sid($sid),"User Inbox","");
echo "<div align=\"center\"><div class=\"top\">Messages</div>";
echo getshoutbox($sid);
$res = "";
if($_POST["submit"])
{
$count = 0;
foreach($_POST["check"] as $value)
{
$pmid = $value;
$pminfo = mysql_fetch_array(mysql_query("SELECT text, byuid, touid, reported FROM test_private WHERE id='".$pmid."'"));
if ($uid==$pminfo[2])
{
if($pminfo[3]!=1)
{
$yes = mysql_query("DELETE FROM test_private WHERE id='".$pmid."'");
if($yes)
{
$count++;
}
}
}
}
$res = "<b>$count Messages Successfully Deleted!</b><br>";
}
echo "<form action=\"inbox.php\" method=\"get\">";
echo "View: <select name=\"view\">";
echo "<option value=\"all\">All</option>";
echo "<option value=\"snt\">Sent</option>";
echo "<option value=\"str\">Starred</option>";
echo "<option value=\"urd\">Unread</option>";
echo "</select>";
echo "<input type=\"hidden\" name=\"do\" value=\"$do\"/>";
//echo "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
echo "<input type=\"submit\" value=\"Go\"/>";
echo "</form><br/>";
echo "</div>";
$view = safe(cleanInput($_GET["view"]));
//////ALL LISTS SCRIPT <<
if($view=="")$view="all";
if($page=="" || $page<=0)$page=1;
$myid = getuid_sid($sid);
$doit=false;
$num_items = getpmcount($myid,$view); //changable
$items_per_page= 10;
$num_pages = ceil($num_items/$items_per_page);
if($page>$num_pages)$page= $num_pages;
$limit_start = ($page-1)*$items_per_page;
if($num_items>0)
{
if($doit)
{
$exp = "&rwho=$myid";
}else
{
$exp = "";
}
//changable sql
if($view=="all")
{
$sql = "SELECT
a.name, b.id, b.byuid, b.unread, b.starred FROM test_users a
INNER JOIN test_private b ON a.id = b.byuid
WHERE b.touid='".$myid."' AND b.folderid='0'
ORDER BY b.timesent DESC
LIMIT $limit_start, $items_per_page
";
}
else if($view=="fldr"){
$sql = "SELECT
a.name, b.id, b.byuid, b.unread, b.starred FROM test_users a
INNER JOIN private_folders b ON a.id = b.byuid
WHERE b.touid='".$myid."' b.folderid='".$folderid."' AND b.starred = '1'
ORDER BY b.timesent DESC
LIMIT $limit_start, $items_per_page
";
}else if($view=="snt")
{
$sql = "SELECT
a.name, b.id, b.touid, b.unread, b.starred FROM test_users a
INNER JOIN test_private b ON a.id = b.touid
WHERE b.byuid='".$myid."'
ORDER BY b.timesent DESC
LIMIT $limit_start, $items_per_page
";
}else if($view=="str")
{
$sql = "SELECT
a.name, b.id, b.byuid, b.unread, b.starred FROM test_users a
INNER JOIN test_private b ON a.id = b.byuid
WHERE b.touid='".$myid."' AND b.starred='1'
ORDER BY b.timesent DESC
LIMIT $limit_start, $items_per_page
";
}else if($view=="urd")
{
$sql = "SELECT
a.name, b.id, b.byuid, b.unread, b.starred FROM test_users a
INNER JOIN test_private b ON a.id = b.byuid
WHERE b.touid='".$myid."' AND b.unread='1'
ORDER BY b.timesent DESC
LIMIT $limit_start, $items_per_page
";
}
echo "<div class=\"nav\">Inbox</div><hr/><div align=\"left\">";
echo $res;
$items = mysql_query($sql);
echo mysql_error();
echo '<form action="inbox.php?do=main" method="post">';
while ($item = mysql_fetch_array($items))
{
if($item[3]=="1")
{
$iml = "<small>[_]</small>";
}else{
if($item[4]=="1")
{
$iml = "<small>[str]</small>";
}else{
$iml = "<small>[x]</small>";
}
}
$lnk = "<a href=\"pm-$item[1].php\">$iml$item[0]</a>";
$pmtext = mysql_fetch_array(mysql_query("SELECT text FROM test_private WHERE id='".$item[1]."'"));
$mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
//$mtext = parsepm($mprev, $sid);
echo '<input type="checkbox" name="check[]" value="'.$item[1].'"/>';
echo "$lnk: $mprev..";
echo "<br/>";
}
echo '<br><input type="submit" name="submit" value="delete"/>';
echo '</form>';
echo "</div>";
echo "<div align=\"center\">";
$npage = $page+1;
echo "<hr/><a href=\"inbox.php?do=sendto\">Send Message</a><br/>";
if($page>1)
{
$ppage = $page-1;
echo "<a href=\"inbox.php?do=main&page=$ppage&view=$view$exp\">«Prev</a> ";
}
if($page<$num_pages)
{
$npage = $page+1;
echo "<a href=\"inbox.php?do=main&page=$npage&view=$view$exp\">Next»</a>";
}
echo "<br/>$page of $num_pages<br/>";
if($num_pages>2)
{
$rets = "<form action=\"inbox.php\" method=\"get\">";
$rets .= "Go To Page: <input name=\"page\" style=\"-wap-input-format: '*N'\" size=\"2\"/>";
$rets .= "<input type=\"submit\" value=\"Go\"/>";
$rets .= "<input type=\"hidden\" name=\"do\" value=\"$do\"/>";
//$rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
$rets .= "<input type=\"hidden\" name=\"view\" value=\"$view\"/>";
$rets .= "</form>";
echo $rets;
echo "<br/>";
}
echo "<form action=\"inbxproc.php?do=proall\" method=\"post\">";
echo "Delete: <select name=\"pmact\">";
echo "<option value=\"red\">Read</option>";
echo "<option value=\"unrd\">Unread</option>";
echo "<option value=\"ust\">Unstarred</option>";
echo "<option value=\"all\">All Msg</option>";
echo "</select>";
echo "<input type=\"submit\" value=\"Go\"/>";
echo "</form></div>";
echo "<div align=\"center\"><a href=\"inbox.php?do=crfolder\">Create New Folder</a><br/>";
echo "<a href=\"inbox.php?do=myfolder\">My Folders</a><br/>";
}else{
echo "<div align=\"center\">";
echo "You Have No Private Messages<br/><a href=\"inbox.php?do=sendto\">Send Message</a><br/>";
echo "<div align=\"center\"><a href=\"inbox.php?do=crfolder\">Create New Folder</a><br/>";
echo "<a href=\"inbox.php?do=myfolder\">My Folders</a><br/>";
echo "</div>";
}
////// UNTILL HERE >>
echo "<div align=\"center\">";
$plc = mysql_fetch_array(mysql_query("SELECT saan FROM test_users WHERE id='".$uid."'"));
echo "<br/><a href=\"$plc[0]\">Exit Inbox</a> ";
echo "<a href=\"index.php?do=forums\">Forums</a> <a href=\"index.php?do=chat\">Chatrooms</a> <a href=\"main.php\">";
echo "Home</a><hr/><div class=\"footer\">$mysite</div>";
echo "<br/>Script Timer ";
$load = microtime();
print (number_format($load,2));
echo " sec";
echo "</div>";
echo "</body>";
}
Comment