In Database Row Day = {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday}
PHP代碼
$today = date('l');
$result = mysql_query("SELECT * FROM alert WHERE Day = '$today' ");
我想知道我怎樣才能從MySQL數據庫按照今天的一天獲取數據?
In Database Row Day = {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday}
PHP代碼
$today = date('l');
$result = mysql_query("SELECT * FROM alert WHERE Day = '$today' ");
我想知道我怎樣才能從MySQL數據庫按照今天的一天獲取數據?
試試這個
$result = mysql_query("SELECT * FROM alert WHERE FORMAT(Now(),'YYYY-MM-DD') AS PerDate = FORMAT(your_col,'YYYY-MM-DD') ");
嘗試
mysql_query("SELECT * FROM alert WHERE Day = DAYNAME('2008-05-15')");
更多信息http://www.w3resource.com/mysql/date-and-time-functions/mysql-dayname-function.php
嘗試這個 -
<?php
$jd=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
$today=jddayofweek($jd,1);
$result = mysql_query("SELECT * FROM alert WHERE Day = '$today' ");
?>
嘗試
<?php
$today = date('l'); // get day of week today;(its 'L' in lowercase)
$result = mysql_query("SELECT * FROM alert WHERE Day = '{$today}' ");
?>