0
if($_SESSION['periode']){
if($_SESSION['periode'] == 'Today'){
$xdate = time() - (1 * 24 * 60 * 60);
$ydate = time();
}
if($_SESSION['periode'] == 'Yesterday'){
$xdate = time() - (2 * 24 * 60 * 60);
$ydate = time() - (1 * 24 * 60 * 60);
}
if($_SESSION['periode'] == 'This week'){
$xdate = time() - (7 * 24 * 60 * 60);
$ydate = time() - (2 * 24 * 60 * 60);
}
if($_SESSION['periode'] == 'Older'){
$xdate = 0;
$ydate = time() - (7 * 24 * 60 * 60);
}
else{
$xdate = 0;
$ydate = time();
}
}
else {
$xdate = 0;
$ydate = time();
}
$tweets = mysql_query("SELECT * FROM messages WHERE content LIKE '%$search%'
AND content LIKE '%$region%'
AND time BETWEEN $xdate AND $ydate ORDER BY id DESC LIMIT 10");
問題:所有消息都是從數據庫中選擇的,而不僅僅是$ xdate和$ ydate之間的消息。'if語句'中的PHP time()未傳遞給MySql查詢?
但是,如果我在else語句中手動填充unix時間段(並且不要定義$ _SESSION ['periode']),則會從DB中選取正確的消息。這是怎麼回事??
我必須使用ELSEIF昨天/本週/舊的,當然!哇,我沒有看到...謝謝! – 2011-02-16 13:41:30