我想在bootstrap缩略图中显示一些数据。我不明白为什么它不显示从数据库中提取的任何数据。数据库连接是正确的。
<div class="jumbotron">
<div class="container">
<center>
<h1> Welkom!</h1>
<p>Op de website van Ter Bruggen Antiek en Curiosa.<br />Voor uw mooiste antieke kroonluchters, lampen, meubelen en overige producten.</p>
<p><a class="btn btn-primary btn-lg disabled" href="?page=info" role="button">Meer weten?</a></p>
</center>
</div>
</div>
<div class="container">
<center>
<h2>Uitgelicht!</h2>
</center>
<div class="row">
<?php
$sql = "SELECT * FROM advertentie, categorie WHERE advertentie.categorie_id = categorie.categorie_id AND uitgelicht=1";
$result = $connect->query($sql);
if ($result->num_rows > 0){
while ($row = $result -> fetch_assoc()){
echo "<div class='col-lg-3'>";
echo "<div class='thumbnail'";
echo "<img class='img-square img-responsive' src='../img/uploads/".$row['filename']."'/> ";
echo "<div class='caption'>";
echo "<h4>".$row['advertentietitel']."</h4>";
echo "<p>".$row['categorie_naam']."</p>";
echo "<p>".$row['verkooprijs']."</p>";
echo "<p><a href='?page=details&id=".$row['advertentie_id']." class='btn btn-primary'>Bekijk</a></p>";
echo "</div>";
echo "</div>";
echo "</div>";
}
}
?>
</div>
</div>
答案 0 :(得分:0)
您的选择查询不正确。你应该使用mysql的JOIN。我不知道你的数据库结构。如果您显示数据库结构,那么我可以帮助您。请尝试以下查询并分享结果
$sql = "SELECT advertentie.* FROM advertentie LEFT OUTER JOIN categorie on advertentie.categorie_id = categorie.categorie_id WHERE advertentie.uitgelicht=1";