Sorry for the incredibly blonde moment, but I'm just WAY lost on this one ...
I need the result to look like:
ProjectID - ProjectName Employee Date Hours
_____________________________________________________________________________
P122345 - project 1 bob 01/01/2004 2.00
carol 01/01/2004 4.00
ron 01/01/2004 1.00
7.00
bob 02/02/2004 1.00
ron 02/02/2004 8.00
9.00
********************************************************************** 16.00
P122346 - project 2 zack 04/01/2004 6.50
carol 04/01/2004 1.50
8.00
rick 04/04/2004 3.50
bob 04/04/2004 2.00
5.50
********************************************************************** 13.50
Any my current code looks like:
$result = mysql_query("select time.empid
, emp.name
, time.project, project.weight
, project.description
, date_format(time.tsdate,'%m/%d/%Y')
, sum(hours)
from time
inner
join project
on time.project = project.project
inner
join emp
on time.empid = emp.empid
group
by time.project, project.description, time.empid, emp.name, date_format(time.tsdate,'%m/%d/%Y')
order
by project.weight desc, time.project desc
, time.empid asc");
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$proj=mysql_result($result,$i,"project");
$descr=mysql_result($result,$i,"description");
echo "<tr><td width=650>$proj - $descr</td><td width=175></td><td width=100></td><td width=50 align=right></td></tr>";
$result1 = mysql_query("select empid, DATE_FORMAT(tsdate,'%m/%d/%Y'), SUM(hours), hours FROM time WHERE project='$proj' GROUP BY empid, tsdate ORDER BY empid ASC, tsdate ASC ");
while(list($tempid, $tdate, $shours, $thours) = mysql_fetch_row($result1)) {
$result2 = mysql_query("SELECT name FROM emp WHERE empid='$tempid'");
while ($Erow = mysql_fetch_array($result2)) {
$result4 = mysql_query("SELECT SUM(hours) FROM time WHERE (project='$proj' AND empid='$tempid')");
while ($Srow = mysql_fetch_array($result4)) {
echo '<tr bgcolor="' . ( (($count++) % 2 ) ? "#FFFFFF" : "#DCDCDC" ) . '">';
echo "<td width=650></td><td width=175>$Erow[0]</td><td width=100>$tdate</td><td width=50 align=right>$shours</td></tr>";
++$i;
echo "<td width=650></td><td width=175></td><td width=100></td><td width=50 align=right>$Srow[0]</td></tr>";
}
}
}
}
Can you make more sense out of this?
Thanks!!