2014-03-26 84 views
0

數據庫詞條今天根據數據庫mysql提取數據? PHP

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數據庫按照今天的一天獲取數據?

回答

0

試試這個

$result = mysql_query("SELECT * FROM alert WHERE FORMAT(Now(),'YYYY-MM-DD') AS PerDate = FORMAT(your_col,'YYYY-MM-DD') "); 
0

嘗試這個 -

<?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' "); 
?> 
0

嘗試

<?php 
$today = date('l'); // get day of week today;(its 'L' in lowercase) 
$result = mysql_query("SELECT * FROM alert WHERE Day = '{$today}' "); 
?> 
相關問題