Ok...
So I have a string which in this case checks the date with the PHP date('Ymd H:i:s'); I want this to check with a database row, if it's larger than.
$sql="SELECT * FROM date WHERE '$this->dateClose' < start_time AND '$this->dateOpen' < end_time";
It's in a loop so it will print everything which has a start_time less than dateClose and the opposite for dateOpen and end_time. But it doesn't work, please help.
尝试使用WHERE field operator value_to_match
并以正确的格式更改值以匹配datetime
$sql="SELECT * FROM date WHERE start_time > '".date('Y-m-d H:i:s', strtotime($this->dateClose))."' AND end_time < '".date('Y-m-d H:i:s', strtotime($this->dateOpen))."'";
请尝试这个
$sql="SELECT * FROM date WHERE '".$this->dateClose."' < start_time AND '".$this->dateOpen."' < end_time";
For the given values
start_time = 2014-11-01 21:00 end_time = 2014-11-02 19:00
$this->dateOpen = 2014-11-01 20:00 $this->dateClose = 2014-11-02 18:00
geting no rows from sql is OK. There is no valid row for your condition
WHERE '2014-11-02 18:00' < start_time AND '2014-11-01 20:00' < end_time'
the '2014-11-02 18:00' < '2014-11-01 21:00'
part is false. You have to rethink what you want to get from your sql.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.