我有这个旋转木马,我想要动态。要进行操作,旋转木马必须以类
开头 <div class="item active">
并且必须远离while循环。在第四个记录提取之后,该类必须简单地
<div class="item">
总结:
0 to 4 -> <div class="item active">
5 to 8 --><div class="item">
9 to 12 --> <div class="item"> ....so on
如何计算提取的记录? 感谢
<?php
$banner = "SELECT * FROM tbl_banner";
$result_b = dbQuery($banner);
// here --> <div class="item active"> or <div class="item">
while($row_b = dbFetchAssoc($result_b)) {
extract($row_b);
?>
<div class="col-md-3">
<div class="w-box inverse">
<div class="figure">
<img alt="" src="banner/<?php echo $img; ?>" class="img-responsive">
<div class="figcaption bg-2"></div>
<div class="figcaption-btn">
<a href="banner/<?php echo $img; ?>" class="btn btn-xs btn-one theater"><i class="fa fa-plus-circle"></i> Zoom</a>
<a href="#" class="btn btn-xs btn-one"><i class="fa fa-link"></i> View</a>
</div>
</div>
<div class="row">
<div class="col-xs-9">
<h2><?php echo $img_title; ?></h2>
<small><?php echo $img_desc; ?></small>
</div>
</div>
</div>
</div>
<?php
}
?>
答案 0 :(得分:1)
您可以使用num_rows
查看返回的行数。不幸的是,从你的问题我无法判断你是使用MySQL,MySQLi还是PDO,因为你似乎把所有的查询都传递给了一个类。
对于MySQLi,请使用以下内容:
$num = $result_b->num_rows;
答案 1 :(得分:0)
SELECT COUNT(*) AS cnt FROM tbl_banner
OR
count( $res ); # in php
另见:Which is fastest? SELECT SQL_CALC_FOUND_ROWS FROM `table`, or SELECT COUNT(*)
答案 2 :(得分:0)
我不明白...... 我希望得到这样的结果,用这种方式解释:
$query ="SELECT .....
<div class="row">
<div class="item active">
while {
<div1>...</div>
<div2>...</div>
<div3>...</div>
<div4>...</div>
} //end while
</div>
</div>
<div class="row">
<div class="item">
while {
<div4>...</div>
<div6>...</div>
<div7>...</div>
<div8>...</div>
} //end while
等等