开发者

php mysql where clause using Date

Can anyone help me with the following开发者_StackOverflow社区?

$crDate = date("Y-m-d");
$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId."AND crDate = ".$crDate;

What I'm trying to do is update a table "callrecord" where the crDate is current date. when I take the And part out, it works fine.

$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId;

this works fine. But I want to check with current date too. any help?


You can use MySQL function curdate() without calculating it within php.

$sql = "update callrecord set crEndtime = Now() 
        where crUsId = '$crUsId' AND crDate = curdate()";


I think you should try using single quotes arround the $crDate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜