I am trying to create some HTML using php/mysql.
My HTML should be something like below:
<div class="row">
<div>Content Block</div>
<div>Content Block</div>
<div>Content Block</div>
<div>Content Block</div>
</div>
<div class="row">
<div>Content Block</div>
<div>Content Block</div>
<div>Content Block</div>
<div>Content Block</div>
</div>
..........
<div class="row">
<div>Content Block</div>
<div>Content Block</div>
<div>Content Block</div>
<div>Content Block</div>
</div>
There are 4 content divs in each row.
This is how I tried it in my PHP while loop, but its not work for me.
while($stmt->fetch()) {
if($i % 4 == 0) {
$html = "<div class='row'>\n";
}
$html .= " <div class='checkbox col-sm-3'>\n";
$html .= " <label>\n";
$html .= " <input class='custom' name='facility[$fid]' type='checkbox'>\n";
$html .= " <span class='lbl'> {$fname}</span>\n";
$html .= " </label>\n";
$html .= " </div>\n";
if($i++ % 4 == 4) {
$html .= " </div>\n";
}
$ckbxOurPut[] = $html;
}
Can anybody tell me what it the wrong with this?
Thank you.
.rowdiv.$ckbxOurPutand why it is inside loop ?