Hi i have this script, and values get posted from a form, checkboxes, user can select Mark as Unread or delete from a drop down box and the script acts accordingly, however, it only acts on the first in the list. So i guess the loop isnt working and i cant figure out why not. Any ideas? thanx alot
<?php
session_start();
include 'db.php';
$test = $_POST['box'];
$username = $_SESSION['username'];
$message = '<font face="verdana"><font color="#FF0000"><font size="1">Please select an action to perform.<br />';
$message2 = '<font face="verdana"><font color="#FF0000"><font size="1">Please select one or more private messages to operate on.<br />';
if (!($_POST['menu'] == '-Select-')) {//not nothing selected
if (!($_POST['box'] == NULL)) {
if ($_POST['menu'] == 'Delete') {
foreach ($_POST['box'] as $key => $value) {
if ($value == true) {
mysql_query("UPDATE mail SET touser='delete-$username' AND id='$key'")or die (mysql_error());
} else $fail2 = 1;
include 'mail_read.php';
exit();
}
}
}
if (!($_POST['box'] == NULL)) {
if ($_POST['menu'] == 'Mark As Unread') {
foreach ($_POST['box'] as $key => $value) {
if ($value == true) {
mysql_query("UPDATE mail SET beenread='0' WHERE id='$key'")or die (mysql_error());
} else $fail2 = 1;
include 'mail_read.php';
}
}
}
}//end mark read
// end nothing selected //
else {
$fail = 1;
include 'mail_read.php';
exit();
}
include 'mail_read.php';
exit(); ?>