Thanks. I'm getting closer..but am still coming up just a bit short. Hoping someone can help me out here, I'm so close, but just can't seem to get the last bit to work properly!! Grrr!!!
So far I've been able to get this result:
JOHN SMITH
3-01-2008 1.5 Hours 1.5 Hours
3-15-2008 0.25 Hours 1.75 Hours
JANE JOHNSON
3-01-2008 1.5 Hours 1.5 Hours
3-15-2008 2.0 Hours 3.5 Hours
As you can see, I'm getting it to keep a running tally of the total hours for each individual. That's close to what I want, but I cannot seem to figure this out.
What am I missing in order to get that "total_hours" amount into a row beneath the running list of dates/hours.
In other words, I want the above example (which is what I'm getting now), to look like this:
JOHN SMITH
3-01-2008 1.5 Hours
3-15-2008 0.25 Hours
Total Hours: 1.75 Hours
JANE JOHNSON
3-01-2008 1.5 Hours
3-15-2008 2.0 Hours
Total Hours: 3.5 Hours
The code currently looks like this:
$sql = "
SELECT u.ID,u.First,u.Last,
p.ID as ProjectID,
p.Name as ProjectName,
h.Hours,
h.Summary,
h.WorkDate
FROM
cust_project_hours h
INNER JOIN
cust_projects p ON p.ID=h.ProjectID
LEFT JOIN
users u ON u.ID=h.UserID
WHERE
h.WorkDate BETWEEN date('$_GET[startDate]') AND date('$_GET[endDate]')
ORDER BY
u.Last,u.First,p.ID
";
Code to display the list of individuals, hours filed, and total hours (not currently working).
$sumTotalHours = 0;
print "<table cellspacing=1 cellpadding=2 border=0 width=400>";
$lastProject='';
$lastDeveloper='-';
while($row=$result->FetchRow()) {
$sumTotalHours += $row['Hours'];
$developer=$row['First'].' '.$row['Last'];
if($developer==' ')$developer='* UNASSIGNED *';
$project=$row['ProjectName'];
if($lastDeveloper!=$developer){
$sumIndHours = 0;
print "<tr>";
print "<td colspan=5 style='border-bottom:2px solid #cccccc;'><h5>".htmlentities($developer)."</h5></td>";
print "</tr>";
$lastDeveloper=$developer;
}
$sumIndHours += $row['Hours'];
print "<tr>";
print "<td width=10> </td>";
print "<td class='smtxt bline' align=left>Updated: ".date('M jS',strtotime($row['WorkDate']))." Hours: ".$row['Hours']."</td>";
print "<td>$sumIndHours</td>";
print "</tr>";
;
}
print "<tr>";
print "<td><br><br><br><br>Total Hours: $sumTotalHours</td>";
print "</tr>";
print "</table>";
print "</div>";
Please help, I'm so close, but so stuck!!
Thank you in advance.