I have this CSS styles layout, as you can see there are two different containers col-1
andcol-grid
<div class="col-1">
<div class="article-two">
<img src="https://i.imgur.com/fNiFRdd.jpg" />
</div>
</div>
<div class="col-grid">
<div class="article-two">
<img src="https://i.imgur.com/fNiFRss.jpg" />
</div>
<div class="article-two">
<img src="https://i.imgur.com/fNiFRfN.jpg" />
</div>
<div class="article-two">
<img src="https://i.imgur.com/fNiFRkN.jpg" />
</div>
</div>
To obtain the same design I have used the PHP concatenation -> .=
but the data is repeated and the same design of the structure is not obtained HTML
where only one image goes in the first container and more than one image can go in the second container, given to the error what changes should be added to the code to get the same layout of the structureHTML
$DivCol = '<div class="col-1">';
$DivColGrid = '<div class="col-grid">';
while ($stmt->fetch()) {
$DivCol .= '<div class="article-two">
<img src="'.$cover_page.'">
</div>';
$DivColGrid .= '<div class="article-two">
<img src="'.$cover_page.'">
</div>';
}
$DivColGrid .= '</div>';
$DivCol .= '</div>';
This is the error I get as a result, the data printout was with a limit de 3
in the queryMYSQL
<div class="col-1">
<div class="article-two">
<img src="https://i.imgur.com/QCcU9VB.jpg" />
</div>
<div class="article-two">
<img src="https://i.imgur.com/Sy5jQrQ.jpg" />
</div>
<div class="article-two">
<img src="https://i.imgur.com/t6MofoQ.jpg" />
</div>
</div>
<div class="col-grid">
<div class="article-two">
<div class="article-two">
<img src="https://i.imgur.com/QCcU9VB.jpg" />
</div>
<div class="article-two">
<img src="https://i.imgur.com/Sy5jQrQ.jpg" />
</div>
<div class="article-two">
<img src="https://i.imgur.com/t6MofoQ.jpg" />
</div>
</div>
</div>
I think you can try the following:
in this case I have added the variable
$first
with valuetrue
: The first time it will add the first record to the first$DivCol
and the rest of the times to$DivColGrid
.I hope it works for you.