<?php
$sql = $empire->query("select * from {$dbtbpre}ecms_app where isgood=1 and bigpic !='' order by newstime limit 3");
$bqno = 1;
while($r = $empire->fetch($sql)) {
$class = ($bqno === 1) ? 'box_current' : '';
?>
<div class="<?= $class ?>">
<img src="<?=$r['titlepic']?>" alt="<?=$r['title']?>">
<div>
<p><?= $bqno ?>. <?=$r['title']?></p>
</div>
</div>
<?php
$bqno++;
}
?>
代码解释:
调用app数据表中推荐等级为1并且bigpic不为空的3条数据,如果是第1条则输出样式div class=”box_current
“,其他则不输出任何样式。
发表评论