PHP MySQL 日期比较
我有一个 Mysql,其中包含行 Data1、data2、data3...Data7,我想与当前日期进行比较,在互联网上搜索到目前为止我得到了这个:
$curDate = date("Y-m-d");
$query = "SELECT Id FROM Programacao where Data1 = $curDate";
$result = mysql_query($query);
if(!$result) {echo 'Nada';}
while ($row = mysql_fetch_array($result))
{
echo "Id = ".$row ['Id'];
}
但我只能读取第一个,是否可以比较所有他们同时?
I Have a Mysql with the rows Data1,data2,data3...Data7 and i want to compare with the current date,searching the internet i got this so far:
$curDate = date("Y-m-d");
$query = "SELECT Id FROM Programacao where Data1 = $curDate";
$result = mysql_query($query);
if(!$result) {echo 'Nada';}
while ($row = mysql_fetch_array($result))
{
echo "Id = ".$row ['Id'];
}
But i can read only the first one,does it possible to compare all of them at the same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用逻辑运算符。如果您需要检查
数据
是$ curdate
,则应替换
或
和(如果需要)检查所有这些都可以。此外,据我记得,您应该在报价中使用日期值,所以正确的是
You should use logic operators. If you need check that AT LEAST ONE of
Data
is$curDate
You should replace
or
byand
if you need to check that ALL OF THEM are OK.Besides, As far as I remember You should use Date values in quotes, so correct one is