rhock_95 Posted March 9, 2008 Share Posted March 9, 2008 anyone have a snippet that will display a (default text ad) string the same as a $row result in a while loop ? I would like to display a Google Adsense Ad about every 10 row or so... TIA Link to comment https://forums.phpfreaks.com/topic/95231-display-adsense-text-ad-every-10th-row-of-query-results/ Share on other sites More sharing options...
BlueSkyIS Posted March 9, 2008 Share Posted March 9, 2008 i would count the lines of output and whenever the line count divided by 10 leaves no remainder, i would echo or include the google adsense code. Link to comment https://forums.phpfreaks.com/topic/95231-display-adsense-text-ad-every-10th-row-of-query-results/#findComment-487878 Share on other sites More sharing options...
corbin Posted March 9, 2008 Share Posted March 9, 2008 $i = 0; while(<some condition>) { if($i % 10 == 0) { //number evenly divided by 10 } $i++; } Or: $i = 0; while(<some condition>) { if($i == 10) { $i = 0; //number is 10 } $i++; } Link to comment https://forums.phpfreaks.com/topic/95231-display-adsense-text-ad-every-10th-row-of-query-results/#findComment-487914 Share on other sites More sharing options...
rhock_95 Posted March 9, 2008 Author Share Posted March 9, 2008 $i = 0; while(<some condition>) { if($i % 10 == 0) { //number evenly divided by 10 } $i++; } Or: $i = 0; while(<some condition>) { if($i == 10) { $i = 0; //number is 10 } $i++; } OK thanks...but I am going to need more information on how to use this... my current "While" statement looks like: while ($row=mysql_fetch_array($result)) how is this effected? also... where in the if statement where/how would I echo the Adsense text string? thanks again... Link to comment https://forums.phpfreaks.com/topic/95231-display-adsense-text-ad-every-10th-row-of-query-results/#findComment-487963 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.