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.
精彩评论