Jump to content

Archived

This topic is now archived and is closed to further replies.

last_trace

Displaying Results, something, Then more results, etc.

Recommended Posts

I am wondering how to do this with my ads. Look below..


Website Link
Website Link
Website Link

ADVERTISEMENT

Website Link
Website Link
Website Link


I 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.

Share this post


Link to post
Share on other sites
Use the % (modular) operator :)

[code]<?php
$link="www.domain.com";
$i=1;
while($i<100){ //let's say we want to print 100 times
if($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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.