Forum Moderators: coopster
if($_POST["item$i"]== "checked"){
$_SESSION['total'] = $total-$ordersArray[$itr+4];
unset ($ordersArray[$itr]);
unset ($ordersArray[$itr+1]);
unset ($ordersArray[$itr+2]);
unset ($ordersArray[$itr+3]);
unset ($ordersArray[$itr+4]);
unset ($ordersArray[$itr+5]);
array_unshift ($ordersArray, array_shift ($ordersArray));
$itr-6;
$i++;
continue;
}
Checkbox code down here:
echo '<input type="checkbox" name="item';
echo $i;
echo '" value="checked">';
$itr + 6; //doesn't change the $itr - it returns just a number
But so the $itr isn't changed nor by unset ($ordersArray[$itr+3]);
eg:
$itr = 2;
unset ($ordersArray[$itr+3]); //ordersArray[5], itr = 2
$itr - 6;// = -4, itr = 2
$itr++;// itr = 3
$itr += 6; //itr = 9
So you see. You don't have to do itr-6, as it's not working as such.
BTW there's no for loop in your example. And what's $i? And what's $itr?
Hope this shows you some direction
Best regards
Michal Cibor
PS. Moreover if you write your checkbox name as
<input type="checkbox" name="item[]"> etc.. you will find that all checkbox turned into an array containing true and false (depends on the check). It may be easier to operate on array that on item$i