如何将echo $ row ['$ d']; 的值设置为auto以跟随datetime。例如,如果date = Apr,那么echo内部的值应为$ row [' Apr '];没有改变manualy。
<?php
date_default_timezone_set("Asia/Kuala_Lumpur");
$today = strtotime("today");
$d=strtotime("-1 Month");
include("config/view-graph.php");
$sql = "SELECT * FROM settings where id = '1'";
$result = $conn->query($sql); if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo date("M", $d). "<br>";
echo $row['Apr'];
} } else { echo "0 results"; } $conn->close(); ?>
答案 0 :(得分:1)
将其分配给变量并使用它: -
$day_name =date("M", $d). "<br>";
echo $row[$day_name];