日期:2014-05-17 浏览次数:20551 次
<?php
$sql="select * from record where officecode='$officecode' and searchtime like '%$riqi%' order by name limit $offset,$Page_size" ;
$result=mysql_query($sql,$link);
$last=array();
while($row=mysql_fetch_array($result)){
if($last){
$row['xingshi'] = (strtotime($row['arrivetime'])-strtotime($last['gotime']))/60;
if($row['name'] == $last['name']) { //还是同一组
$distance += $row['distance']; //计算合计距离
$xingshi += $row['xingshi']; //计算行驶时间
}
else {
//当组别变化时,行驶时间为0
$row['xingshi'] = 0;
?>
<td colspan="4" bgcolor="#E0EEE">合计</td>
<td><div align="center">
<?php echo $distance."km"; ?>
</div></td>
<td><?php echo $xingshi."min"; ?></td>
<?php
//合计完成后,重置行驶距离和行驶时间
$distance = $row['distance'];
$xingshi = 0;
}
}
else {
//每个name第一次进入时的行驶距离和时间
$distance = $row['distance'];
$xingshi = 0;
}
$last=$row;
?>