Heres a snip of my code which is causing the problem:
$content = "<table border='0' cellspacing='0' cellpadding='5'>\n";
$content .= "<tr>\n";
$content .= "<td> </td>\n";
$tasks = new dbconnect;
$tasks->connect();
$tasks->query("SELECT tid, tname FROM tasks");
while(list($tid, $tname) = $tasks->fetch_rows()) {
$content .= "<td valign='top' align='center'><span class='highlight'>$tname</span></td>\n";
}
$content .= "<td> </td>\n";
$content .= "</tr>\n";
$projects = new dbconnect;
$projects->connect();
$projects->query("SELECT pid, pname FROM projects");
* $columntotals = array();*
$colour = 0;
while(list($pid, $pname) = $projects->fetch_rows()) {
$tasks->data_seek(0);
$rowtotal = 0;
$count = 0;
if ($colour % 2) {
$bgcolour = "#FFFFFF";
}
else {
$bgcolour = "#F9F9F9";
}
$colour++;
$content .= "<tr>\n";
$content .= "<td valign='top' align='center'><span class='highlight'>$pname</span></td>\n";
while(list($tid, $tname) = $tasks->fetch_rows()) {
$logs = new dbconnect;
$logs->connect();
$logs->query("SELECT SUM(hours) from logs WHERE pid = '$pid' AND tid = '$tid' AND date >= '$sdate' AND date <= '$edate'");
list($sum) = $logs->fetch_rows();
if (!$sum) {
$sum = 0;
}
$rowtotal = $rowtotal + $sum;
*$columntotals[$count] = $columntotals[$count] + $sum;*
$count++;
$content .= "<td bgcolor='$bgcolour' align='center'>$sum</td>\n";
}
$content .= "<td align='center'><b>$rowtotal</b></td>\n";
}
$content .= "</tr>\n";
$content .= "<tr>\n";
$content .= "<td> </td>\n";
$sumofcolumntotals = 0;
for ($i=0; $i<sizeof($columntotals); $i++)
{
$sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
$content .= "<td align='center'><b>$columntotals[$i]</b></td>\n";
}
$content .= "<td align='center'><b>$sumofcolumntotals</b></td>\n"; $content .= "</tr>\n"; $content .= "</table>\n";
I have made the lines inwhich I know are causing problems in bold. Basicly, I am creating a report of some data and need to count up totals of each column and then again total the totals if you get me.
Here is the errors I am getting.
*Notice*: Undefined offset: 0 in *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 1 in *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 2 in *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 3 in *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58
*Now I understand in a way why its happening, because im trying to insert into $columntotals something which isnt valid, but I can't think of a way to stop this at the moment.
Hope to hear soon, thanks in advance guys.
-noginn
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php