Jump to content

Displaying Results, something, Then more results, etc.


last_trace

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.
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.