Welcome to WebmasterWorld Guest from 54.224.17.208

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Inserting code between items in a loop

Show an ad after 2 loops

     
8:59 pm on Jun 4, 2007 (gmt 0)

10+ Year Member



I need to show an evil advertisement after every two loops in order to get rich. I have my "while" loop, simplified for illustration. How to I put a javascript call after each 2 rows?


while($result = mysql_fetch_array( $data ))
{
echo "a bunch of HTML";
echo "<div class=\"descr\">Posted on " . date('D j M Y',$result['posted']);
echo CutText(strip_tags($result['descr'], '<example>'),100);
}
9:08 pm on Jun 4, 2007 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Here's where a little math comes in :)

$counter = 0;
while($result = mysql_fetch_array( $data ))
{
if(($counter % 3) == 0) { #uses the modulus operator (%)
#print javascript
}
$counter++;
echo "a bunch of HTML";
echo "<div class=\"descr\">Posted on " . date('D j M Y',$result['posted']);
echo CutText(strip_tags($result['descr'], '<example>'),100);
}

good luck

1:20 pm on Jun 5, 2007 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I need to show an evil advertisement after every two loops in order to get rich.

I lol'ed. Thanks for starting my day right monkeythumpa. :)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month