什麼是正確的方式來使用MySQL TIMEDIFF,(或類似的)?在數據庫中我有一個名爲date的列,它設置CURRENT_TIMESTAMP。我試圖計算連續CURRENT_TIMESTAMP和現在之間的differene,比呼應,爲所有的行..這是我的腳本sql timediff函數
<?php
mysql_connect("localhost","root","");//database connection
mysql_select_db("beyondmotors");
$result = mysql_query("SELECT * FROM currentrentals");
echo "<table border='2'>
<tr>
<th>ID</th>
<th>Year</th>
<th>Make</th>
<th>Model</th>
<th>First Name</th>
<th>Last Name</th>
<th>Insurance</th>
<th>Date</th>
<th>Notes</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['year'] . "</td>";
echo "<td>" . $row['make'] . "</td>";
echo "<td>" . $row['model'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['insurance'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['notes'] . "</td>";
echo ("<td><a href=\"edit_form.php?id=$row[id]\">Edit</a></td></tr>");
echo "</tr>";
}
echo "</table>";
在此先感謝