I'm trying to add a container every 2 iterations. I've implemented a count, but I'm getting weird results as I inspect the page.
Any ideas what may be going on and what I may be doing wrong with the wrapper injection?
<?php
include "includes2014_new/db_conx.php";
$sql ="SELECT * FROM articles WHERE id ORDER BY id DESC LIMIT 5";
$resultsHome = mysqli_query($db_conx,$sql);
$productCount = mysqli_num_rows($resultsHome); // count the output amount
if ($productCount > 0) {
$counter = 1;
while($row = mysqli_fetch_array($resultsHome)){
$id = $row["id"];
$article_title = $row["article_title"];
$category = $row["category"];
$readmore = $row["readmore"];
$author = $row["author"];
$date_added = $row["date_added"];
$content = $row["content"];
$short = substr(strip_tags($content), 0, 80);
if (($counter % 2) === 1) {
$blogList .= '<div class="clearer">';
}
//----------------
if($readmore == ''){
$blogList .= '<div class="col span_6_of_12 postBox textLeft fulltwelvepadfix">
<div class="section miniPad">
<div class="col span_8_of_12">'.$article_title.'</div>
<div class="col span_4_of_12"><img src="images/'.$id.'.jpg" height="80px" width="100px" alt="'.$category.' " /></div>
</div>
<div class="section miniPad">
<div class="col span_12_of_12">'.$date_added.' - '.$author.'</div>
<div class="col span_12_of_12"><p>'.$short.'[...]</p></div>
<div class="section group"><a href="r.php?id='.$id.'">Read More</a></div>
</div>
<div class="comments section group">
<div class="commentsInner">Comments(0)</div>
</div>
</div>';
}
else {
$blogList .= '<div class="col span_6_of_12 postBox textLeft fulltwelvepadfix">
<div class="section miniPad">
<div class="col span_8_of_12">'.$article_title.'</div>
<div class="col span_4_of_12"><img src="images/'.$id.'.jpg" height="80px" width="100px" alt="'.$category.' " /></div>
</div>
<div class="section miniPad">
<div class="col span_12_of_12">'.$date_added.' - '.$author.'</div>
<div class="col span_12_of_12"><p>'.$short.'[...]</p></div>
<div class="section group"><a href="'.$readmore.'">Read More</a></div>
</div>
<div class="comments section group">
<div class="commentsInner">Comments(0)</div>
</div>
</div>';
}
//----------------
if (($counter % 2) === 0) { $blogList .= '</div>'; }
$counter++;
}
}
?>