Ok I know this question has been asked before and we have run through a lot of different answers... However we still can't get this working right.
This is higher up in the code where the threads are displayed. It is also nested inside of an echo that is displaying the table. Except for the that is marked by comments, all the others are not next to code like they are shown. I wanted the code to highlight the right way.
<?php //More code here~
while ($x = $s->fetch_object()){
$c = $c==1?2:1;
echo '<tr>
<td style="border: 1px solid #1f2a19; padding-left: 5px; padding-right: 5px; " class="color1" width="1%" nowrap>
<input type="checkbox" class="check" name="check[]" value="'.($x->id).'" /></td>
//More displaying table code here.
';
}$s->close(); ?>
Lower down in the code near where the buttons appear at the end of the page we have this.
<?php
if (u::isstaff()) {
?> <!--This is here because the file is an .php and most of the code is php.
Very little HTML is used.-->
<input type="submit" name="delete" value="Delete"/>
<?php // Same with this one. It is in the code.
if(isset($_POST['delete']))
{
$cnt=array();
$cnt=count($_POST['check']);
for($i=0;$i<$cnt;$i++)
{
$del_id=$_POST['check'][$i];
$query=("delete from forumposts where 'thread'='$del_id'");
mysql_query($query);
$query=("delete from forumthreads where 'id'='$del_id'");
mysql_query($query);
} //for
} //ispost delete
} //isstaff ?>
The goal of this code to is grab the Thread id number from the checkboxes and run it through a deletion function when a button is pressed. Giving staff members the power to delete multi threads in a board at once.
This code works only to delete a single thread and is what we are basing the multi delete thread function on. It is in a different file "thread.php"
<?php if ($_GET['act'] == 'deletethread'){
if (!u::ismod()) return f::deny();
$db->query("DELETE FROM forumposts
WHERE `thread`='{$thread->id}'");
if ($db->error) die(trigger_error($db->error) );
$db->query("DELETE FROM forumthreads
WHERE `id`='{$thread->id}'");
if ($db->error) die(trigger_error($db->error) );
s::go('board?i='.$thread->board);
}?>
========================================================
So I think I have failed on the button... Never learned Java before. This is what the middle section looks like now. I have the feeling that I am still doing the delete part wrong as well.
<input type="submit" name="delete" value="Delete"/>
<?php
if(isset($_POST['check_list'])){
$cnt=array();
$cnt=count($_POST['check_list']);
for($i=0;$i<$cnt;$i++)
{
$ids = implode(',', $_POST['check_list']);
mysqli_query("delete from forumposts where id in ($ids)");
mysqli_query($query);
mysqli_query("delete from forumthreads where id in ($ids)");
mysqli_query($query);
} //for
} //ispost delete
} //isstaff
?>