last_trace Posted August 8, 2006 Share Posted August 8, 2006 I am wondering how to do this with my ads. Look below..Website LinkWebsite LinkWebsite LinkADVERTISEMENTWebsite LinkWebsite LinkWebsite LinkI want to be able to display 3 results, then show 1 ad, then show 3 more. So for every 3 results, it returns a ad, then 3 more if there are more.I wasn't sure if I could do this with foreach some how or not. Quote Link to comment Share on other sites More sharing options...
Orio Posted August 8, 2006 Share Posted August 8, 2006 Use the % (modular) operator :)[code]<?php$link="www.domain.com";$i=1;while($i<100){ //let's say we want to print 100 timesif($i%4==0){echo("ad");}else{echo $link;}}?>[/code]Basicly, we check in each round if $i can be devided by 4, and if so print ad :)Orio. Quote Link to comment Share on other sites More sharing options...
last_trace Posted August 8, 2006 Author Share Posted August 8, 2006 Wow, that was wicked fast and it worked.Thank you so much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.