0
從輸出中,你可以看到,我可以選擇MIN(TIME(Time))
但是當我在TIMEDIFF FUNCTION
使用它,它讀取MIN(TIME(Time))
爲0,我得到的-07結果:00 :00。我想知道MIN(TIME(Time))
和07:00:00的區別,以確定員工遲到的小時數。對於如何解決這個問題,有任何的建議嗎?所有回覆都非常感謝。對不起,英文不好。
下面的代碼:
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<?php
$con=mysqli_connect("localhost","root","","september-system");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "SELECT User_ID, MIN(TIME(Time)) as time, DATE(Time) as day, TIMEDIFF('MIN(TIME(Time))', '07:00:00')as tdiff FROM records GROUP BY User_ID, day ORDER BY User_ID, day;";
if (mysqli_multi_query($con,$sql))
{
do
{
// Store first result set
if ($result=mysqli_store_result($con)) {
echo "<table><tr><th>USER ID</th><th>TIME</th><th>DATE</th><th>ABSENCES</th></tr>";
// output data of each row
while ($row=mysqli_fetch_row($result))
{
//echo var_dump($row);
echo "<tr><td>" . $row[0]. "</td><td>" . $row[1]. "</td><td>" . $row[2]. "</td><td>" . $row[3]. "</td></tr>";
}
// Free result set
mysqli_free_result($result);
}
}
while(mysqli_more_results($con) && mysqli_next_result($con));
}
mysqli_close($con);
?>
我沒有檢查,但我可以先說變量,然後在它們之間做出不同。 – Virb
@Virb我該怎麼做?我真的很抱歉,我是PHP新手,我一直在做的是搜索網絡。 –