I need to print out a div that encapsulates three li's in them as I run through a list in a DB. As I am using bootstrap, I need to div with a .row-fluid for every row after the third column of .span4, but I'm having a bit of trouble getting the for loop working.. here is the untouched code:\[code\]<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="http://stackoverflow.com/questions/15869534/#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>\[/code\]I need that top parent div of row-fluid surrounding the list item after every third print from the DB..