如何显示最新的预订日期结果

时间:2017-01-15 08:41:06

标签: php date

如何在$date > strtotime("now")显示最新的预订结果,因为我只能显示预订记录。

这是我的PHP代码

$mysqli = new mysqli("", "", "", "");

$stmt = $mysqli->prepare("SELECT bookingid, date, slot, location FROM booking WHERE username=?");

$stmt->bind_param("s", $username); 

$stmt->execute();

$stmt->bind_result($bookingid, $date, $slot, $location);

        echo"<table>";
        echo"<b>Latest Bookings</b>";
        echo "<tr><th><b>Date</b></th>
        <th><b>Slot</b></th>
        <th><b>Location</b></th>
        <th><b>Actions</b></th>";

            while ($stmt->fetch()) {
                if( $date > strtotime("now")) {
                echo "<tr>";
                echo "<td><p>$date";
                echo "<td><p>$slot</td>";
                echo "<td><p>$location</td>";

                echo "</tr>";
                echo "</table>";
            }
        else{
            echo"<table>";
            echo"<b>Booking History</b>";
            echo "<tr><th><b>Date</b></th>
            <th><b>Slot</b></th>
            <th><b>Location</b></th>";
            while ($stmt->fetch()) {

                echo "<tr>";

                echo "<td><p>$date";
                echo "<td><p>$slot</td>";
                echo "<td><p>$location</td>";

                echo "</tr>";
                echo "</table>";
        }
        }
}

1 个答案:

答案 0 :(得分:0)

$date > strtotime("now")更改为此strtotime($date) > strtotime("now"),我希望它能正常工作