However as soon as I click to delete or email just number 10, without number 5 ticked, on the post page it shows that for some reason number 5 is now the option!
Also I cant get the last row of the array (the update button itself) to stop interering.
Heres the code, test and you'll see what I mean.
Code: Select all
<?php
if(!$_POST['update'])
{ ?> <form action="test" name="caf" method="post">
<table width="40%" cellspacing="1" cellpadding="4" class="table">
<tr>
<td class="headbars">-</td>
<td width="5%" class="headbar2">Email</td>
<td width="4%" class="headbar2" align="center">Delete</td>
</tr><tr><td class="cell">5</td>
<td width="5%" class="cell"><input name="email[]" type="checkbox" value="1" checked="checked" />1</td>
<td width="4%" class="cell" align="center">
<input name="delete[]" type="checkbox" id="delete[]" value="1" />
<input type="hidden" name="tid[]" value="5" /></td>
</tr><tr><td class="cell">10</td>
<td width="5%" class="cell">
<input name="email[]" type="checkbox" value="1" checked="checked" />1 </div></td>
<td width="4%" class="cell" align="center">
<input name="delete[]" type="checkbox" id="delete[]" value="1" />
<input type="hidden" name="tid[]" value="10" />
</td></tr></table>
<input name="update" class="button" type="submit" value="Update Subscriptions" /></form><? }
else
{
$tid = $_POST['tid'];
$email = $_POST['email'];
$delete = $_POST['delete'];
$while = (count($_POST['tid']));
print_r($_POST); echo '<br /><br />';
while($while >= 0) {
$while--; $a++;
$tidu = $tid["$while"];
#$email[$while] = ($email[$while] == 1) ? 1 : 0;
#$delete[$while] = ($delete[$while] == 1) ? 1 : 0;
if($delete[$while] == 1)
#{query("DELETE FROM $forumzDB.forumz_subscribe WHERE tid = '$tid[$while]' AND uid = '$uid'");}
{echo "delete thread $tidu, $delete[$while]<br />";}
elseif($tidu != 1 || $tidu == '')
{echo "updated $tidu, set email to $email[$while]<br />";}
#query("UPDATE $forumzDB.forumz_subscribe SET email = '$email[$while]' WHERE tid = '$tidu' AND uid = '$uid'");}
}#end while
}#end if
#success_box('Subscriptions updated.', "$HTTP_REFERER");
#header("Location: ".$forum_properties['base_url']."/edit_subscriptions");
?>