1
$link = new PDO("mysql:host=localhost;dbname=fashion",'root','');
$stmt=$link->prepare("select * from stylestatement where id='".$_REQUEST["you"]."'");
    if ($stmt->execute(array($_GET['title']))) {
        $row=$stmt->fetch();
        $newstmt=$link->prepare("select * from images where `statementid`='".$_REQUEST["you"]."' and `added_on`='".$row["created_on"]."'");
        $newstmt->execute();
        echo($newstmt->rowCount());
    }

在上面的代码中,即使我在图像表中有相同的日期时间,我也得到了 result=0,为什么?

4

1 回答 1

0

您需要使用日期方法将日期与数据库进行比较。所以在你的 where 条件下使用date( added_on)代替added_on那将匹配日期。

代替

$newstmt=$link->prepare("select * from images where `statementid`='".$_REQUEST["you"]."' and `added_on`='".$row["created_on"]."'");  

$newstmt=$link->prepare("select * from images where `statementid`='".$_REQUEST["you"]."' and date(`added_on`)='".$row["created_on"]."'");
于 2013-10-17T05:49:32.793 回答