我使用PHP的PDO扩展程序从数据库中检索数据。我从来没有遇到过这个问题,它总是出现在所有浏览器中。但是当我在朋友笔记本电脑上测试网站时,foreach循环可以工作,但内容不会显示。内容存在于源代码中。
这就是我设置应该显示的代码的方式:
<?php
foreach($advertentiesManager->recenteAdvertenties() as $advertentie) {
$verkoperData = $usersManager->userData($advertentie->verkoper);
?>
<div class="col-md-4" style="margin:10px 0;">
<div class="advertentie">
<div class="overlay"></div>
<div class="img" style="background:url('images/categorie/<?php echo $advertentie->categorie; ?>.jpg') no-repeat center center;background-size:cover;"></div>
<a href="profiel/<?php echo $advertentie->verkoper; ?>"><div class="picture" style="background:url('<?php echo str_replace("../", "", $verkoperData->foto); ?>') no-repeat center center;background-size:cover;"></div></a>
<div class="prijs"><p class="h2">€ <?php echo $advertentie->verkoopprijs; ?></p></div>
<div style="padding: 10px;padding-left:80px;margin-top:-40px;">
<a href="<?php echo $advertentie->type.'/'.strtolower(str_replace(" ", "-", $advertentie->titel)).'-'.$advertentie->id; ?>">
<?php echo $advertentie->titel; ?>
</a>
<br>
<p style="color:#777;font-size:.9em;">
<?php
$beschrijving = strip_tags($advertentie->omschrijving);
$max_length = 100;
if (strlen($beschrijving) > $max_length) {
$offset = ($max_length - 3) - strlen($beschrijving);
$beschrijving = substr($beschrijving, 0, strrpos($beschrijving, ' ', $offset)) . '... <a href="'.$advertentie->type.'/'.strtolower(str_replace(" ", "-", $advertentie->titel.'-'.$advertentie->id)).'">Meer</a>';
} else {
$beschrijving = $advertentie->omschrijving;
}
echo $beschrijving;
?>
</p>
</div>
</div>
</div>
<?php
}
?>
您可以在http://www.coupontrade.nl/查看实时示例,内容应显示在&#34; Recente广告&#34;在twitter部分之上。