什么是正确的方式来使用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>";
在此先感谢