checkbox problem

Started on the old forum in April 2011 · view the original in the archive · old links redirect here

15 replies · 965 views · started 15 years ago · 2 min read

4 participants
whitewingz Developer · 64 posts #1

hi guyz what is my wrong here it's not working.. when i check 1 of checkbox then try do delete it and submit it's says only Message Deleted Successfully but it's really not delleted in inbox.. here's my code..

if(isset($_POST['submit'])) {
 
$pmid = safe(cleanInput($_GET["pmid"]));

 $id = $_POST['check'];
foreach($_POST['check'] as $value) {

mysql_query("DELETE FROM ibwf_private WHERE id='".$value."'");
 

}
 
$del = mysql_query("DELETE FROM ibwf_private WHERE id='".$value."'");
if($del)
{
$del = mysql_query("DELETE FROM ibwf_private WHERE id='".$value."'");
echo "Message Deleted Successfully";
}else{
echo "Can't Delete Message At The Moment";
}

 

} 
    $view = safe(cleanInput($_GET["view"]));
    //////ALL LISTS SCRIPT <<
    if($view=="")$view="all";
    if($page=="" || $page<=0)$page=1;
    $myid = getuid_sid($sid);
    $doit=false;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND folderid='0'"));
    $num_items = $noi[0]; //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 ibwf_users a
            INNER JOIN ibwf_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=="snt")
  {
    $sql = "SELECT
            a.name, b.id, b.touid, b.unread, b.starred FROM ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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
    ";
  }
    
  

    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
$i++;
 $avlink = getavatar($item[2]);
      if($item[3]=="1")
      {
        $iml = "[_]";
      }else{
        if($item[4]=="1")
        {
            $iml = "[S]";
        }else{

        $iml = "[x]";
        }
      }
      $delete = "$item[1]";
      $lnk = "<form method=\"POST\" action=\"inbox.php\"><input type=\"checkbox\" name=\"check[]\" value=\"$item[1]\"><a href=\"inbox_readpm.php?pmid=$item[1]\">$iml$item[0]</a>";
      
      $pmtext = mysql_fetch_array(mysql_query("SELECT text FROM ibwf_private WHERE id='".$item[1]."'"));
      $mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
      //$mtext = parsepm($mprev, $sid);
      echo "$lnk: $mprev..";
      echo "<br/>";

    }

echo "<hr />";
/*<a href=\"inbox.php?a=all&page=1\">select all</a> with selected <select name=\"opt\"><option value=\"1\">Move to Archive</option><option value=\"2\" selected>Delete</option></select>
";*/
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form></div><hr/>";

$npage = $page+1;
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"inbox.php?page=$ppage&view=$view$exp\">«Prev</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"inbox.php?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;
    }

thanks for those who help me:D

kei_ki7 Senior · 431 posts #2
if(isset($_POST['submit'])) {
 
$pmid = safe(cleanInput($_GET["pmid"]));

$id = $_POST['check'];
$noc = count($id);
for($i=0; $i < $noc; $i++)
{
	$del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
}
 
if($del)
{
echo "Message Deleted Successfully";
}else{
echo "Can't Delete Message At The Moment";
}
 
} 
    $view = safe(cleanInput($_GET["view"]));
    //////ALL LISTS SCRIPT <<
    if($view=="")$view="all";
    if($page=="" || $page<=0)$page=1;
    $myid = getuid_sid($sid);
    $doit=false;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND folderid='0'"));
    $num_items = $noi[0]; //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 ibwf_users a
            INNER JOIN ibwf_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=="snt")
  {
    $sql = "SELECT
            a.name, b.id, b.touid, b.unread, b.starred FROM ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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
    ";
  }
    
  

    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
$i++;
 $avlink = getavatar($item[2]);
      if($item[3]=="1")
      {
        $iml = "[_]";
      }else{
        if($item[4]=="1")
        {
            $iml = "[S]";
        }else{

        $iml = "[x]";
        }
      }
      $delete = "$item[1]";
      $lnk = "<form method=\"POST\" action=\"inbox.php\"><input type=\"checkbox\" name=\"check[]\" value=\"$item[1]\"><a href=\"inbox_readpm.php?pmid=$item[1]\">$iml$item[0]</a>";
      
      $pmtext = mysql_fetch_array(mysql_query("SELECT text FROM ibwf_private WHERE id='".$item[1]."'"));
      $mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
      //$mtext = parsepm($mprev, $sid);
      echo "$lnk: $mprev..";
      echo "<br/>";

    }

echo "<hr />";
/*<a href=\"inbox.php?a=all&page=1\">select all</a> with selected <select name=\"opt\"><option value=\"1\">Move to Archive</option><option value=\"2\" selected>Delete</option></select>
";*/
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form></div><hr/>";

$npage = $page+1;
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"inbox.php?page=$ppage&view=$view$exp\">«Prev</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"inbox.php?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;
    }  

Try this.

Did I help you? You can help me too Your donations will help me finance my studies.

kei_ki7 Senior · 431 posts #4
    $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");

Check this, because i edit a while ago.

And also try to change this

if(isset($_POST['submit'])) {

to

if(!empty($_POST['check'])) {

Did I help you? You can help me too Your donations will help me finance my studies.

whitewingz Developer · 64 posts #5

kei_ki7 wrote:

    $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");

Check this, because i edit a while ago.

And also try to change this

if(isset($_POST['submit'])) {

to

if(!empty($_POST['check'])) {

ok thanks let me try it..

Added after 14 minutes:

its still not working here is the code

if(!empty($_POST['check'])) { 
$pmid = safe(cleanInput($_GET["pmid"]));
$id = $_POST['check'];
$noc = count($id);
for($i=0; $i < $noc; $i++)
{
 $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
}
if($del)
{
echo "Message Deleted Successfully";
}else{
echo "Can't Delete Message At The Moment";
}
}
something else Fellow · 2,296 posts #7

Is your checkbox name called "check" on the form?

kei_ki7 Senior · 431 posts #8

This code works, I did not just code. I also try it. Btw do you use ibwf_ in your database?

if(isset($_POST['check'])) {
	$id = $_POST['check'];
	$noc = count($id);
	for($i=0; $i < $noc; $i++)
	{
		$del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
	}
	if($del){
		echo "Message Deleted Successfully";
	}else{
		echo "Can't Delete Message At The Moment";
	}
} 

Did I help you? You can help me too Your donations will help me finance my studies.

something else Fellow · 2,296 posts #9

Slight update (incase last message doesnt delete)

if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        echo "$a/$noc Messages Deleted Successfully";
    }else{
        echo "Can't Delete Messages At The Moment";
    }
}
whitewingz Developer · 64 posts #10

something else wrote: Slight update (incase last message doesnt delete)

if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        echo "$a/$noc Messages Deleted Successfully";
    }else{
        echo "Can't Delete Messages At The Moment";
    }
}

if(isset($_POST['check'])) { $id = $_POST['check']; $noc = count($id); for($i=0; $i < $noc; $i++) { $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'"); } if($del){ echo "Message Deleted Successfully"; }else{ echo "Can't Delete Message At The Moment"; } }

it's not working also... when i try to mark 2 or 3 message to delete it's say only 1/1 Messages Deleted Successfully

i try dis but it'a also not working

1st i try $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."' AND folderid='0'");

second i try dis $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."' AND touid='".$uid."' AND reported !='1' AND starred !='1' AND folderid !='1' and unread='0'");

something else Fellow · 2,296 posts #12

it sounds like your form is wrong ... post it here 🙂

whitewingz Developer · 64 posts #13

here's my code mate

  echo "<head>";
  echo "<title>PM Inbox</title>";
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$white[0]\"/>";
  echo "</head>";

echo "<div class=\"top\">PM INBOX</div><hr/><div class=\"center\">";
echo getshoutbox($sid);
echo "</div></div><hr/><div class=\"nav\">PM Messages</div><hr/>";
echo "<div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a></div><hr/><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;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND folderid='0'"));
    $num_items = $noi[0]; //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 ibwf_users a
            INNER JOIN ibwf_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=="snt")
  {
    $sql = "SELECT
            a.name, b.id, b.touid, b.unread, b.starred FROM ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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
    ";
  }
    
    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
$i++;
 $avlink = getavatar($item[2]);
      if($item[3]=="1")
      {
        $iml = "[_]";
      }else{
        if($item[4]=="1")
        {
            $iml = "[S]";
        }else{

        $iml = "[x]";
        }
      }
      $delete = "$item[1]";
      $lnk = "<form method=\"POST\" action=\"inbox.php\"><input type=\"checkbox\" name=\"check[]\" value=\"$item[1]\"><a href=\"inbox_readpm.php?pmid=$item[1]\">$iml$item[0]</a>";
      
      $pmtext = mysql_fetch_array(mysql_query("SELECT text FROM ibwf_private WHERE id='".$item[1]."'"));
      $mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
      //$mtext = parsepm($mprev, $sid);
      echo "$lnk: $mprev..";
      echo "<br/>";

    }

echo "<hr />";
if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        echo "$a/$noc Messages Deleted Successfully";
    }else{
        echo "Can't Delete Messages At The Moment";
    }
}  
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form></div><hr/>";

$npage = $page+1;
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"inbox.php?page=$ppage&view=$view$exp\">«Prev</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"inbox.php?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;
    }

    }else{

      echo "You Have No Private Messages<a href=\"inbox.php?do=sendto\">Send Message</a>";

    }

  ////// UNTILL HERE
echo "<hr><div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"javascript: history.go(-1)\">Exit PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a> <a href=\"index.php\">Home</a></div>";
$plc = mysql_fetch_array(mysql_query("SELECT saan FROM ibwf_users WHERE id='".$uid."'"));
echo "<div class=\"footer\">";
echo "$mysite</div>";
echo "<div class=\"timer\"><a href=\"index.php?do=signoff\" accesskey=\"0\">LogOut</a> <a href=\"terms.php\" accesskey=\"1\">Help</a></div>";
echo "<div class=\"timer\">Script Timer ";
$load = microtime();
print (number_format($load,5));
echo "s";
echo "</div>";
  echo "</body>";
  }
something else Fellow · 2,296 posts #14

Should be something like:

  echo "<head>";
  echo "<title>PM Inbox</title>";
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$white[0]\"/>";
  echo "</head>";

echo "<div class=\"top\">PM INBOX</div><hr/><div class=\"center\">";
echo getshoutbox($sid);
echo "</div></div><hr/><div class=\"nav\">PM Messages</div><hr/>";
echo "<div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a></div><hr/><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;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND folderid='0'"));
    $num_items = $noi[0]; //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 ibwf_users a
            INNER JOIN ibwf_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=="snt")
  {
    $sql = "SELECT
            a.name, b.id, b.touid, b.unread, b.starred FROM ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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
    ";
  }
    
    $items = mysql_query($sql);
    echo mysql_error();
    echo "<form method=\"POST\" action=\"inbox.php\">";
    while ($item = mysql_fetch_array($items))
    {
$i++;
 $avlink = getavatar($item[2]);
      if($item[3]=="1")
      {
        $iml = "[_]";
      }else{
        if($item[4]=="1")
        {
            $iml = "[S]";
        }else{

        $iml = "[x]";
        }
      }
      $delete = "$item[1]";
      $lnk = "<input type=\"checkbox\" name=\"check[]\" value=\"$item[1]\"><a href=\"inbox_readpm.php?pmid=$item[1]\">$iml$item[0]</a>";
      
      $pmtext = mysql_fetch_array(mysql_query("SELECT text FROM ibwf_private WHERE id='".$item[1]."'"));
      $mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
      //$mtext = parsepm($mprev, $sid);
      echo "$lnk: $mprev..";
      echo "<br/>";

    }

echo "<hr />";
if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        echo "$a/$noc Messages Deleted Successfully";
    }else{
        echo "Can't Delete Messages At The Moment";
    }
}  
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form></div><hr/>";

$npage = $page+1;
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"inbox.php?page=$ppage&view=$view$exp\">«Prev</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"inbox.php?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;
    }

    }else{

      echo "You Have No Private Messages<a href=\"inbox.php?do=sendto\">Send Message</a>";

    }

  ////// UNTILL HERE
echo "<hr><div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"javascript: history.go(-1)\">Exit PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a> <a href=\"index.php\">Home</a></div>";
$plc = mysql_fetch_array(mysql_query("SELECT saan FROM ibwf_users WHERE id='".$uid."'"));
echo "<div class=\"footer\">";
echo "$mysite</div>";
echo "<div class=\"timer\"><a href=\"index.php?do=signoff\" accesskey=\"0\">LogOut</a> <a href=\"terms.php\" accesskey=\"1\">Help</a></div>";
echo "<div class=\"timer\">Script Timer ";
$load = microtime();
print (number_format($load,5));
echo "s";
echo "</div>";
  echo "</body>";
  }  

You was creating a new form for every checkbox

kei_ki7 Senior · 431 posts #15
if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        echo "$a/$noc Messages Deleted Successfully";
    }else{
        echo "Can't Delete Messages At The Moment";
    }
} 

I thnk you need this code in upper part.

I'll take a test. Wait for a while

Done testing, Hope it will work.

echo "<head>";
  echo "<title>PM Inbox</title>";
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$white[0]\"/>";
  echo "</head>";

if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        $delMsg = "$a/$noc Messages Deleted Successfully";
    }else{
        $delMsg =  "Can't Delete Messages At The Moment";
    }
}

echo "<div class=\"top\">PM INBOX</div><hr/><div class=\"center\">";
echo getshoutbox($sid);
echo "</div></div><hr/><div class=\"nav\">PM Messages</div><hr/>";
echo "<div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a></div><hr/><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;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND folderid='0'"));
    $num_items = $noi[0]; //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 ibwf_users a
            INNER JOIN ibwf_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=="snt")
  {
    $sql = "SELECT
            a.name, b.id, b.touid, b.unread, b.starred FROM ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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
    ";
  }
    
    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
$i++;
 $avlink = getavatar($item[2]);
      if($item[3]=="1")
      {
        $iml = "[_]";
      }else{
        if($item[4]=="1")
        {
            $iml = "[S]";
        }else{

        $iml = "[x]";
        }
      }
      $delete = "$item[1]";
      $lnk = "<form method=\"POST\" action=\"inbox.php\"><input type=\"checkbox\" name=\"check[]\" value=\"$item[1]\"><a href=\"inbox_readpm.php?pmid=$item[1]\">$iml$item[0]</a>";
      
      $pmtext = mysql_fetch_array(mysql_query("SELECT text FROM ibwf_private WHERE id='".$item[1]."'"));
      $mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
      //$mtext = parsepm($mprev, $sid);
      echo "$lnk: $mprev..";
      echo "<br/>";

    }

echo "<hr />";
echo $delMsg;
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form></div><hr/>";

$npage = $page+1;
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"inbox.php?page=$ppage&view=$view$exp\">«Prev</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"inbox.php?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;
    }

    }else{

      echo "You Have No Private Messages<a href=\"inbox.php?do=sendto\">Send Message</a>";

    }

  ////// UNTILL HERE
echo "<hr><div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"javascript: history.go(-1)\">Exit PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a> <a href=\"index.php\">Home</a></div>";
$plc = mysql_fetch_array(mysql_query("SELECT saan FROM ibwf_users WHERE id='".$uid."'"));
echo "<div class=\"footer\">";
echo "$mysite</div>";
echo "<div class=\"timer\"><a href=\"index.php?do=signoff\" accesskey=\"0\">LogOut</a> <a href=\"terms.php\" accesskey=\"1\">Help</a></div>";
echo "<div class=\"timer\">Script Timer ";
$load = microtime();
print (number_format($load,5));
echo "s";
echo "</div>";
  echo "</body>";
  }

Did I help you? You can help me too Your donations will help me finance my studies.

ACIDCORE Junior · 30 posts #16

kei_ki7 wrote:

if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        echo "$a/$noc Messages Deleted Successfully";
    }else{
        echo "Can't Delete Messages At The Moment";
    }
} 

I thnk you need this code in upper part.

I'll take a test. Wait for a while

Done testing, Hope it will work.

echo "<head>";
  echo "<title>PM Inbox</title>";
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$white[0]\"/>";
  echo "</head>";

if(isset($_POST['check'])) {
    $id = $_POST['check'];
    $noc = count($id);
    $a = 0;
    for($i=0; $i < $noc; $i++)
    {
        $del = mysql_query("DELETE FROM ibwf_private WHERE id='".$id[$i]."'");
       if($del) $a++;
    }
    if($a>0){
        $delMsg = "$a/$noc Messages Deleted Successfully";
    }else{
        $delMsg =  "Can't Delete Messages At The Moment";
    }
}

echo "<div class=\"top\">PM INBOX</div><hr/><div class=\"center\">";
echo getshoutbox($sid);
echo "</div></div><hr/><div class=\"nav\">PM Messages</div><hr/>";
echo "<div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a></div><hr/><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;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_private WHERE touid='".$uid."' AND folderid='0'"));
    $num_items = $noi[0]; //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 ibwf_users a
            INNER JOIN ibwf_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=="snt")
  {
    $sql = "SELECT
            a.name, b.id, b.touid, b.unread, b.starred FROM ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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 ibwf_users a
            INNER JOIN ibwf_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
    ";
  }
    
    $items = mysql_query($sql);
    echo mysql_error();
    while ($item = mysql_fetch_array($items))
    {
$i++;
 $avlink = getavatar($item[2]);
      if($item[3]=="1")
      {
        $iml = "[_]";
      }else{
        if($item[4]=="1")
        {
            $iml = "";
        }else{

        $iml = "[x]";
        }
      }
      $delete = "$item[1]";
      $lnk = "<form method=\"POST\" action=\"inbox.php\"><input type=\"checkbox\" name=\"check[]\" value=\"$item[1]\"><a href=\"inbox_readpm.php?pmid=$item[1]\">$iml$item[0]</a>";
      
      $pmtext = mysql_fetch_array(mysql_query("SELECT text FROM ibwf_private WHERE id='".$item[1]."'"));
      $mprev = (htmlspecialchars(strlen($pmtext[0])<20?$pmtext[0]:substr($pmtext[0], 0, 15)));
      //$mtext = parsepm($mprev, $sid);
      echo "$lnk: $mprev..";
      echo "<br/>";


    }

echo "<hr />";
echo $delMsg;
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">
</form></div><hr/>";

$npage = $page+1;
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"inbox.php?page=$ppage&view=$view$exp\">«Prev</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"inbox.php?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;
    }



    }else{

      echo "You Have No Private Messages<a href=\"inbox.php?do=sendto\">Send Message</a>";

    }


  ////// UNTILL HERE
echo "<hr><div class=\"center\"><a href=\"inbox_sendto.php\">Send PM</a> <a href=\"javascript: history.go(-1)\">Exit PM</a> <a href=\"inbox.php?view=snt\">Sent Items</a> <a href=\"inbox_folder.php\">Archive</a> <a href=\"index.php\">Home</a></div>";
$plc = mysql_fetch_array(mysql_query("SELECT saan FROM ibwf_users WHERE id='".$uid."'"));
echo "<div class=\"footer\">";
echo "$mysite</div>";
echo "<div class=\"timer\"><a href=\"index.php?do=signoff\" accesskey=\"0\">LogOut</a> <a href=\"terms.php\" accesskey=\"1\">Help</a></div>";
echo "<div class=\"timer\">Script Timer ";
$load = microtime();
print (number_format($load,5));
echo "s";
echo "</div>";
  echo "</body>";
  }

Still not working....

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close