我正在尝试使用按钮从PHP加载数据库中的更多数据。到现在为止,我可以计算结果和显示的结果。因此,当$ count == $ countAll时,通常会显示所有结果。
有人可以解释为什么这行不通吗?
// Count all results
$allResults = $conn->prepare("SELECT*FROM tl_picture WHERE text LIKE '%$innerhtml%' ORDER BY id DESC");
$allResults->execute();
$countAll =$allResults->rowCount();
echo "Found results: ".$countAll."<br>";
//max 20 results showing
$statement = $conn->prepare("SELECT*FROM tl_picture WHERE text LIKE '%$innerhtml%' ORDER BY id DESC limit 20");
$statement->execute();
$collection = $statement->fetchAll();
$count =$statement->rowCount();
echo "viewable results: ". $count;
<script>
<?php if($count==$countAll): ?>
document.GetElementById('loadButton').style.display='none';
} else {
document.GetElementById('loadButton').style.display='block';
}
<?php endif; ?>
</script>
慕姐4208626