I want to break from the loop after every fourth term of number in the loop.
I want to create a list of twenty people; in every tr
should to be 4 people.
So, I want to break from the loop after every 4th number of loop. My one tr
will contain 4 td
and every td
value is incremented with respect to the loop like the first td
will 1 second will 2 and last will 4, then it should break with a new tr
and the value is in td
like I said in increment order.
My code is below:
<?php for ($i = 0 ; $i<=20; $i++){?>
<tr>
<td>
<img src="http://bootdey.com/img/Content/user_1.jpg" alt="">
<a href="<?php echo $i ; // shoud to be 1 ?>" class="user-link">Full name 1</a>
<span class="user-subhead">Member</span>
</td>
<td>
<img src="http://bootdey.com/img/Content/user_1.jpg" alt="">
<a href="<?php echo $i ; // shoud to be 2 ?>" class="user-link">Full name 1</a>
<span class="user-subhead">Member</span>
</td>
<td>
<img src="http://bootdey.com/img/Content/user_1.jpg" alt="">
<a href="<?php echo $i ; // shoud to be 3 ?>" class="user-link">Full name 1</a>
<span class="user-subhead">Member</span>
</td>
<td>
<img src="http://bootdey.com/img/Content/user_1.jpg" alt="">
<a href="<?php echo $i ; // shoud to be 4 ?>" class="user-link">Full name 1</a>
<span class="user-subhead">Member</span>
</td>
</tr>
<?php
if($i%4==0){ echo "<tr></tr>";}
} ?>