Forum Moderators: coopster

Message Too Old, No Replies

Advertising every couple rows

         

pinto172

7:29 pm on Jun 10, 2008 (gmt 0)

10+ Year Member



I have a small classified script and I am curious as to how I would go about setting it up so that every 5 ads it would display advertising.

mooger35

9:24 pm on Jun 10, 2008 (gmt 0)

10+ Year Member



use a count variable in your loop and every time $count%5 == 0 echo your advertising

small example:

//initiate count variable
$count = 1;

//start loop. I'm assuming you are using while
while($row = mysql_fetch_assoc($sql)){

//check to see where count is at, if 5th row display ad
if($count%5 == 0) echo "<tr><td>Your advertising</td></tr>\r\n";

//echo record from mysql
echo "<tr><td>".$row['something']."</td></tr>\r\n";

//add 1 to count
$count++;
}

pinto172

2:35 am on Jun 11, 2008 (gmt 0)

10+ Year Member



Thank you very much!