我使用以下代码从数据库中的数据生成表。它由员工对数据进行分组。我需要的是显示每个employees表末尾的最后四列的总数。小时,OT,旅行和TOT专栏。
代码:
$current_user_name = false;
while($row = mysql_fetch_array($result)) {
// listing a new employee? Output the heading, start the table
if ($row['user_name'] != $current_user_name) {
if ($current_user_name !== false)
echo '</table>'; echo '[divider_padding]';// if we're changing employee, close the table
echo '
<h5>'.$row['last_name'].', '.$row['first_name'].'</h5>[minimal_table]
<table>
<tr>
<th>Date</th>
<th class="tableleft">Description</th>
<th class="tableleft">Job</th>
<th class="tableleft">Activity</th>
<th class="tableleft">Comments</th>
<th class="tableright">Hours</th>
<th class="tableright">OT</th>
<th class="tableright">Travel</th>
<th class="tableright">TOT</th>
</tr>';
$current_user_name = $row['user_name'];
}
// output the row of data
echo '<tr>
<td style="width:75px">'.$row['labor_date'].'</td>
<td class="tableleft">'.$row['description'].'</td>
<td class="tableleft">'.strtoupper($row['job']).'</td>
<td class="tableleft">'.$row['activity'].'</td>
<td class="tableleft">'.$row['comments'].'</td>
<td class="tableright">'.$row['rthours'].'</td>
<td class="tableright">'.$row['othours'].'</td>
<td class="tableright">'.$row['trthours'].'</td>
<td class="tableright">'.$row['tothours'].'</td>
</tr>
';}
echo '</table>[/minimal_table]'; // close the final table
}
?>
我在尝试一些测试后陷入困境,无法解决这个问题。
这是收集数据的查询:
$result = mysql_query("SELECT * FROM data WHERE labor_date BETWEEN '$start' AND '$end' Order by last_name, labor_date ASC");
任何帮助都将不胜感激。
答案 0 :(得分:0)
这一行缺少一个开括号:
if ($current_user_name !== false)
应该是:
if ($current_user_name !== false) {