Gah! having problems passing array through form
Posted: Fri Jan 09, 2009 4:41 pm
Ok, I need to pass an array through a form. Take the code, loop through it and take the value of each element and use that to make a db query. The problem is what get's passed is "Array" and when i loop through, no matter how many checkboxes i check it only goes only and returns "A" instead of lets say "12"
here is an except from the form:
here is where it should delete...:
why is it returning the values A R R A Y and not the actual id? I NEVER HAD this problem before, this code worked on the old server I had, with an older version of php so I am thinking it must be something in the php.ini that needs to be changed. Can anyone please help?
here is an except from the form:
Code: Select all
while ($mail = mysql_fetch_array($query)) {
echo '<tr class="mailbody">'
, '<td width=5><input type="checkbox" name="deleWhatId[]" value="'.$mail[id].'"></td>';
}Code: Select all
$_POST[deleWhatId][0] = $_POST[deleWhatId][0] == '' ? $_POST[deleWhatId] : $_POST[deleWhatId][0];
$countwhat = count($_POST['deleWhatId']);
//if there are actually some elements checked
if ($countwhat) {
//loops through all elements and deletes if that mail belongs to this person BASTARDS try to <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> with it huh?
for($i=0; $i<$countwhat; $i++) {
$findMail = mysql_query("SELECT fid, uid FROM mail WHERE id='$_POST['deleWhatId'][$i]'");
$mail = mysql_fetch_array($findMail);
if (($_POST[act1] == 'itwassent' || $_GET[act1] == 'itwassent') && $mail[fid] == $user[id]) {
mysql_query("UPDATE mail SET wher='2' WHERE id='$_POST['deleWhatId'][$i]'");
$whereFrom = 'Sent Folder';
} elseif ($mail[uid] == $user[id]) {
mysql_query("DELETE FROM mail WHERE uid='$user[id]' AND id='$_POST['deleWhatId'][$i]'");
$whereFrom = 'Inbox';
} else {
$errorMsg = 'There was an error processing your request, the mail did not belong to you.<BR>';
}
}
if ($errorMsg) {
echo '<font color=red>',$errorMsg,'</font>';
} else {
echo '<center><font color=green>You have deleted ',nFormat($i),' piece(s) of mail from your ',$whereFrom,'<BR><BR></font></center>';
}
}