2 回答
TA贡献1821条经验 获得超6个赞
您需要执行查询并获取结果,如下所示:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT DAYNAME(wp_cbxrbooking_log_manager.`booking_date`) as \'weekday\', \n"
. " wp_cbxrbooking_log_manager.`party_size` as \'Party Size\',\n"
. " wp_cbxrbooking_log_manager.`booking_time` as \'Time\',\n"
. " wp_cbxrbooking_log_manager.`mattiscool` as \'# of Reservations\'\n"
. "FROM wp_cbxrbooking_log_manager\n"
. "\n"
. "WHERE `booking_date` >= DATE(NOW()) - INTERVAL 7 DAY \n"
. "ORDER BY `Time` ASC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
- 2 回答
- 0 关注
- 103 浏览
添加回答
举报