$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());
}
在上面的代码中,即使我在图像表中有相同的日期时间,我得到结果= 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"]."'");
关于php - 匹配日期时间不显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19418898/