Does anyone have a simple solution to while looping in PHP for the following HTML structure?
I basically want every 3 divs to have a <li>
separating them so that the slide can work properly, since every <li>
works as a "new page". A template page , if you analyze the source code, it is quite complete and easy to understand.
PHP code
<?php
$fotosEmpresa = $conn->prepare("SELECT * FROM imgs_global WHERE TipoImg = ? ORDER BY rand()");
$fotosEmpresa->execute(array("QuemSomos"));
if($fotosEmpresa->rowCount() > 0): ?>
<ul class="bxslider">
<li>
<div class="row">
<?php while($rowFotoEmpresa = $fotosEmpresa->fetch(PDO::FETCH_OBJ)): ?>
<div class="col-md-4">
<div class="team-post">
<div class="team-gal">
<a href="administracao/imagens/quemsomos/imgG/<?php echo $rowFotoEmpresa->NomeImg; ?>" class="zoom">
<img alt="" src="administracao/imagens/quemsomos/<?php echo $rowFotoEmpresa->NomeImg; ?>">
</a>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</li>
</ul>
<?php endif; ?>
HTML Structure
<ul class="bxslider">
<li>
<div class="row">
<div class="col-md-4">
<div class="team-post">
<div class="team-gal">
<img alt="" src="http://placehold.it/300x378"></div><h2>JohnSmith</h2><span>Webdesigner</span></div></div><divclass="col-md-4">
<div class="team-post">
<div class="team-gal">
<img alt="" src="http://placehold.it/300x378"></div><h2>MikeSmith</h2><span>FounderofaCompany</span></div></div><divclass="col-md-4">
<div class="team-post">
<div class="team-gal">
<img alt="" src="http://placehold.it/300x378"></div><h2>DonaldSmith</h2><span>Development</span></div></div></div></li><li><divclass="row">
<div class="col-md-4">
<div class="team-post">
<div class="team-gal">
<img alt="" src="http://placehold.it/300x378"></div><h2>JohnSmith</h2><span>Webdesigner</span></div></div><divclass="col-md-4">
<div class="team-post">
<div class="team-gal">
<img alt="" src="http://placehold.it/300x378"></div><h2>MikeSmith</h2><span>FounderofaCompany</span></div></div><divclass="col-md-4">
<div class="team-post">
<div class="team-gal">
<img alt="" src="http://placehold.it/300x378"></div><h2>DonaldSmith</h2><span>Development</span></div></div></div></li></ul>
Wehaveseenthatevery%canddthatrepeatsanew"page" is generated for the slider, that is, in the structure it needs to treat that to each number of records it generates a <li>
, something like .