开发者

php mysql where clause using Date

开发者 https://www.devze.com 2023-02-28 21:22 出处:网络
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;

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

精彩评论

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