yah it was a typo lol
really appreciate you helping me with this. its driving me insane. im having a hard time getting help cause its the holidays I guess.
i cant do anything atm until i get this check box working

and I thought i was doing amazing when i got pagination to work. loops and arrays are my huge weak point atm.
i noticed that when I add this in the brackets my select all check box stops working. association[<?php echo $sent_id[0];?>]
Code: Select all
<input type="checkbox" name="association[<?php echo $sent_id[0];?>]" value= "<?php echo $sent_id[0];?>" id="1" />
thats a kewl way to debug and see whats going on in the script
Code: Select all
page accessed
post delete is set
post association is not empty
array element, sent_id: 1, val: 1
deleting id 1
redirect is happening if this die statement wasnt here
Code: Select all
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
<? require("menu.php"); ?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sitestyle.css" />
<script type="text/javascript">
function checkUncheckAll(groupName, checkState){
var groupObj = document.forms[0].elements[groupName];
var groupLen = groupObj.length;
for(var groupIdx=0; groupIdx<groupLen; groupIdx++)
{
groupObj[groupIdx].checked = checkState;
}
return;
}
</script>
</head>
<body>
<table width="88%" height="0" border="0" cellspacing="0">
<tr>
<td height="0" align="center"><a href="inbox.php?inbox=1">Inbox</a>
</td> <td height="0" align="center"><a href="compose.php">Compose</a></td>
<td height="0" align="center"><a href="sent.php?sent=1">Sent</a></td>
<td height="0" align="center"><a href="trash.php">Trash</a></td>
</tr>
<tr>
</table>
<br/ >
<br/ >
<form name="frm1" id="frm1" action="" method="post"
15.onsubmit="javascript:return submitIt('frm1')">
<p>
<center>
<table width="60%" border="1" cellspacing="1" cellpadding="0">
<tr align="center">
</tr>
<tr align="center">
<td><input type="checkbox" name="checkAll" value="x" id="checkall" onclick="checkUncheckAll('association[]', this.checked)" /></td>
<td>Recipient</td>
<td>Subject</td>
<td>Sent</td>
<td>read/unread</td>
</tr>
<?php
// find out how many rows are in the table
$count3 = "SELECT COUNT(*) FROM sent WHERE id = '".($_SESSION['user_id'])."'";;
$count2 = mysql_query($count3) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($count2);
$numrows = $r[0];
// number of rows to show per page
$rowsperpage = 10;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);
// get the current page or set a default
if (isset($_GET['sent']) && is_numeric($_GET['sent'])) {
// cast var as int
$currentpage = (int) $_GET['sent'];
} else {
// default page num
$currentpage = 1;
}// end if
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
}// end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if
// the offset of the list, based on current page
$offset = ($currentpage - 1) * $rowsperpage;
// get the info from the db
$count3 = "SELECT * FROM sent WHERE id = '".($_SESSION['user_id'])."' ORDER BY time DESC LIMIT $offset, $rowsperpage ";
$count2 = mysql_query($count3) or trigger_error("SQL", E_USER_ERROR);
// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($count2)) {
// these are variables to place in the echo
$sent_id = $list['sent_id'];
$recipient = $list['sendto'];
$subject = $list['subject'];
$read = $list['read'];
// grabs the time offset
$take3 = "SELECT time_offset FROM users WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'";
$take2 = mysql_query($take3) or die(mysql_error());
$take1 = mysql_fetch_array($take2);
$recieved = $list['time'];
// adds the users time offset to the inputed time
$time = ($recieved + $take1['time_offset']);
// sets default time to UTC then formats the inputed time that was offset with the users offset
date_default_timezone_set('UTC');
$user_offset = date('h:i:s a M/d', $time);
?>
<tr>
<td><center><input type="checkbox" name="association[<?php echo $sent_id[0];?>]" value= "<?php echo $sent_id[0];?>" id="1" /></center></td>
</label></td>
<td><center><a href="search_goaulds.php?goauld=<?php echo $recipient; ?>"><?php echo $recipient ?></a></center></td>
<td><center><a href="sent_view.php?sent_id=<?php echo $sent_id; ?>"><?php echo $subject ?></a></center></td>
<td><center><?php echo $read ?></center></td>
<td><center><?php echo $user_offset ?></center></td>
</tr>
<?php } // while loop
?>
</table>
</center>
<div class="deletecontainer">
<div class="delete">
<br/>
<input type="submit" name="delete" id="delete" value="Delete"></p>
</form>
</div>
</div>
<?php
echo 'page accessed<br />';
if(isset($_POST['delete'])) {
echo 'post delete is set<br />';
if (!empty($_POST['association']))
{
echo 'post association is not empty<br />';
foreach($_POST['association'] AS $sent_id => $val)
{
echo 'array element, sent_id: ' . $sent_id . ', val: ' . $val . '<br />';
$sent_id = (int) $sent_id;
echo 'deleting id ' . $sent_id . '<br />';
mysql_query('DELETE FROM `sent` WHERE `sent_id`= ' . (int) $sent_id);
}
}
die('redirect is happening if this die statement wasnt here');
header("Location: sent.php?sent=1");
}
?>
</body>
</html>