PHP / MYSQL使用datediff显示mysql记录年龄

时间:2016-11-13 21:37:01

标签: php mysql

我是PHP / MYSQL的新手,我试图使用DATEIFF显示我数据库中所有记录的年龄,如我的代码第17行所示,但它刚赢了& #39;工作。我需要有人帮我解决这个问题。

$result = mysqli_query($con,"SELECT * FROM growers");

echo "<table class='table table-striped table-advance table-hover'>
    <tbody>
        <tr>
            <th><i class='icon_profile'></i>&nbsp;Batch</th>
            <th><i class='icon_ol'></i>&nbsp;Date Received</th>
            <th><i class='icon_clock_alt'></i>&nbsp;Age when Received</th>
            <th><i class='icon_clock_alt'></i>&nbsp;Current Age</th>
            <th><i class='icon_star'></i>&nbsp;NO of Birds</th>
            <th><i class='icon_info'></i>&nbsp;View More</th>
        </tr>";

        while($row = mysqli_fetch_array($result))
        {
            echo"<tr>";
            echo"<td>" . $row['BATCH'] . "</td>";
            echo"<td>" . $row['BIRTH DAY'] . "</td>";
            echo"<td>" . $row['AGE'] . "&nbsp;Week(s)" . "</td>";
            echo"<td>" . "SELECT DATEDIFF("NOW()", "$row['BIRTH DAY']") AS CURRENT AGE". "</td>";
            echo"<td>" . $row['NO OF BIRDS'] . "</td>";
            echo"<td>" . $row['AGE'] . "</td>";
            echo"</tr>";
        }
echo "</table>";

mysqli_close($con);
?>

1 个答案:

答案 0 :(得分:1)

您可以在主要选择中选择

    {
"parameters" : [
{
"address1" : "2455 South Road",
"city" : "Poughkeepsie",
"companyName" : "IBM Research",
"state" : "NY",
"country" : "US",
"postalCode" : "12601",
"firstName" : "Justin",
"lastName" : "Manweiler",
"email" : "rismadm@us.ibm.com",
"permissionSystemVersion" : "1",
"timezoneId" : "117",
"username" : "cu-jmanweiler@us.ibm.com",
"secondaryPasswordTimeoutDays" : 90,
"userStatusId" : 1001
},
"IBMcl0ud!",
"IBMcl0ud!"
]
}