php - Entering three elements at different points in retrieval/list -
i listing batsmen , have page showing top 50. want have 3 separate points in list can enter 3 different elements.
i after 10th, 24th, 42nd batsmen. how go doing php?
my current code retrieves batsmen , in controller has take of 50
@foreach($batsmen $bat) <h2> $bat->name</h2> <h3> $bat->nationality</h3> <h3> $bat->highscore</h3> @endforeach
in normal php use index, , increment index in loop. i'm not clear 3 different elements are, should help:
<?php // here $i index $i = 1; foreach($batsmen $bat){ // when index reaches 10, 24, , 42 add 3 different elements // output here done every iteration of loop // , before ads if( $i == 10 ){ echo '<div id="ad1"></div>'; } if( $i == 24 ){ echo '<div id="ad2"></div>'; } if( $i == 42 ){ echo '<div id="ad3"></div>'; } // here incrementing index $i++; // output here done every iteration of loop // , after ads }
Comments
Post a Comment