0
我有一個php代碼來計算顯示的登錄時間和計數。 但我想結束表格,我想計算每個列結束時的總持續時間和登錄次數。 在rove結束時,我想計算平均登錄時長和平均登錄次數,即總時長/項目數。但不能這樣做。 你能給我一個提示嗎?在PHP中計算表的深度總和平均值
$result = mysql_query("SELECT connection_log.user, `count(*) as 'connection_count', sum(TIMESTAMPDIFF(MINUTE,connection_log.logondate, connection_log.logoffdate)) as `connection_time`
FROM connection_log
INNER JOIN users ON connection_log.user=users.user
WHERE users.groups
LIKE '%cpg_sirket_dyo%' and connection_log.logondate>='2015-09-01 00:00:00' and connection_log.logoffdate<'2015-10-01 00:00:00'
group by connection_log.user
order by connection_count desc",$con);
echo '<table width="80%" border="1" align="center" cellspacing="0" cellpadding="0">';
echo " <tr>
<th> Row number </th>
<th> Username </th>
<th> Total login count </th>
<th> Total login duration(min.) </th>
</tr> ";
$counter = 1;
while ($row = mysql_fetch_array($result, MYSQL_BOTH))
{
echo " <tr>
<td> ". $counter ." </td>
<td> ". $row['user'] . "</td>
<td> ". $row['connection_count'] ." </td>
<td> ". $row['connection_time'] ." </td>
</tr> ";
$counter++;
}
//SUM CALCULATION
//NEED HERE!
//
echo "</table><br>\n";
echo $icounter. " Items<br>\n";
mysql_close($con);
巨大:)謝謝 – TFC