Skip to content

Instantly share code, notes, and snippets.

@wplokal
Created March 19, 2019 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplokal/8db2c18dee1fd6fb3d522f2f3cccddb9 to your computer and use it in GitHub Desktop.
Save wplokal/8db2c18dee1fd6fb3d522f2f3cccddb9 to your computer and use it in GitHub Desktop.
Loop Row with Colum Bootstrap - PHP
<?php
//Columns must be a factor of 12 (1,2,3,4,6,12)
$numOfCols = 4;
$rowCount = 0;
$bootstrapColWidth = 12 / $numOfCols;
?>
<div class="row">
<?php
foreach ($rows as $row){
?>
<div class="col-md-<?php echo $bootstrapColWidth; ?>">
<div class="thumbnail">
<img src="user_file/<?php echo $row->foto; ?>">
</div>
</div>
<?php
$rowCount++;
if($rowCount % $numOfCols == 0) echo '</div><div class="row">';
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment