我有一個名爲DATE的字段的mysql數據庫,將數據存儲爲日期。我正在嘗試獲取php日期,以便從當前日期起爲未來31天選擇記錄。日期範圍之間的查詢不顯示結果
這是我...
$start_THISMONTH = "-1";
if (isset($to_date)) {
$start_THISMONTH = $to_date;
}
$finish_THISMONTH = "-1";
if (isset($from_date)) {
$finish_THISMONTH = $from_date;
}
mysql_select_db($database_WHTSON, $WHTSON);
$query_THISMONTH = sprintf("SELECT * FROM CALENDAR WHERE DATE BETWEEN %s AND %s AND APPROVED = 1 ORDER BY DATE ASC", GetSQLValueString($start_THISMONTH, "date"),GetSQLValueString($finish_THISMONTH, "date"));
$THISMONTH = mysql_query($query_THISMONTH, $WHTSON) or die(mysql_error());
$row_THISMONTH = mysql_fetch_assoc($THISMONTH);
$totalRows_THISMONTH = mysql_num_rows($THISMONTH);
-
設立兩個變量的代碼是
$from_date = date("Y-m-j");
$to_date = date('Y-m-j', strtotime("+31 days"));
和身體我的PHP代碼是
<h4><strong><font color="#FF0000"><?php echo $row_THISMONTH['EVENT_NAME']; ?></font></strong></h4>
<?php $date = date_format($row_THISMONTH['DATE'], 'jS F'); ?>
<h5><em><?php echo $date; ?>, <?php echo $row_THISMONTH['TIMES']; ?><br />
<?php echo $row_THISMONTH['LOCATION_ADDRESS']; ?>, <?php echo $row_THISMONTH['LOCATION_TOWN']; ?> <?php echo $row_THISMONTH['LOCATION']; ?></em><br />
</h5>
<p><?php echo $row_THISMONTH['EVENT_DETAILS']; ?><br />
</p>
無結果ts正在顯示。這是一個新建立的數據庫,只有一條記錄在那裏,情人節的日期。如果我將代碼更改爲簡單的「查找所有記錄」查詢,它顯示很好(雖然date_format不顯示日期。)
這是我的剋星,請幫我理解我做錯了什麼?
當$ start_THISMONTH' ='時,此函數返回GetSQLValueString($ start_THISMONTH,「date」)' 1'? –