当我在数据库中运行一个列表时,我需要打印出一个包含三个 li 的 div。当我使用引导程序时,我需要为 .span4 的第三列之后的每一行使用 .row-fluid 进行 div,但是我在让 for 循环工作时遇到了一些麻烦。这是未触及的代码:
<div class="row-fluid">'
<ul class="thumbnails">
<?php
for($i=0; $i<count($rows); $i+=1){
?>
<!-- This is why sort by programme doesn't work - ID is not what I need -->
<li class="span4" id="<?php echo $rows[$i]['Class']; ?>">
<div class="thumbnail">
<img src="http://placehold.it/320x200" alt="ALT NAME">
<div class="caption">
<h3><?php echo $rows[$i]['Title']; ?></h3>
<?php if(!empty($rows[$i]["DateSold"])){ ?>
<span class="label label-warning" style="margin-bottom: 10px;">Book has been sold!</span>
<?php } ?>
<p>Seller: <?php echo $rows[$i]['FirstName'] . " " . $rows[$i]['LastName']; ?> </p>
<p>Email: <?php echo $rows[$i]['Email']; ?></p>
<p>Cost: <?php echo $rows[$i]['Cost']; ?></p>
<p>Condition: <?php echo $rows[$i]['BookCondition']; ?></p>
<p align="center">
<?php echo '<a href="#myModal' . $i . '" class="btn btn-primary btn-block" data-toggle="modal">View More information</a>' ?>
</p>
</div>
</div>
</li>
<!-- Modal -->
<?php echo'<div id="myModal' . $i . '" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">'; ?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Book information</h3>
</div>
<div class="modal-body">
<p>Title: <?php echo $rows[$i]['Title']; ?> </p>
<p>Seller: <?php echo $rows[$i]['FirstName'] . " " . $rows[$i]['LastName']; ?> </p>
<p>Email: <?php echo $rows[$i]['Email']; ?></p>
<p>Phone: <?php echo $rows[$i]['PhoneNumber']; ?></p>
<p>Condition: <?php echo $rows[$i]['BookCondition']; ?></p>
<p>Date added: <?php echo $rows[$i]['DateAdded']; ?></p>
<p>Class: <?php echo $rows[$i]['Class']; ?></p>
<p>Cost: <?php echo $rows[$i]['Cost']; ?></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<?php
}
?>
</ul>
</div>
在从数据库中每三次打印后,我需要围绕列表项的行流体的顶级父 div ..