我试图while循环信息到SELECT语句中,然后COUNT结果。我尝试了至少10种不同的“解决方案”,但均无效果。我只会得到0、1或什么都没有。这是我最近的尝试:

$query35 = "SELECT * FROM movies WHERE userID = $memberID";
$result35 = $db->query($query35);

while ($row35 = $result35->fetchAll(PDO::FETCH_ASSOC)) {

    $movie = $row35['movie'];

    $query36 = "SELECT COUNT(*) AS similar FROM movies WHERE userID = '$profileID' && movie = '$movie'";
    $result36 = $db->query($query36);
    $row36->fetchObject;

    $similar = $row36['similar'];

    echo $similar;

}

最佳答案

$row36->fetchObject;


似乎是空对象,我认为应该是

$row36 = $result36->fetchObject();

10-04 17:52