Jump to content

[SOLVED] counter issue: 3rd and 9th display


Lambneck

Recommended Posts

hello, The following code displays a list of blog entries. Im trying to set up the code so that it displays an ad after the third and ninth output on the blog. Can anyone point me in the right direction with this?

 

what im working with:

<?php

require_once('load.php');

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die('<strong style="color:maroon">Sorry, database undergoing maintenance. Please try again later.</strong>');

if (!mysql_select_db($database))
    die("Can't select database");

$result = mysql_query("SELECT * FROM $table WHERE submission_date BETWEEN UNIX_TIMESTAMP(DATE_SUB( CURDATE( ) ,INTERVAL 5 DAY )) and UNIX_TIMESTAMP( ) ORDER BY submission_id DESC")or die(mysql_error());

while($row = mysql_fetch_array($result))
{
 $subject = $row['col_2'];
  	echo '<div class="posts">';
  	echo '<h2>';
  	echo '<a href="blog.php?id='.$row['submission_id'].'" class="link">'.stripslashes(htmlspecialchars($row['col_4'])).'</a>';
  	echo '</h2>';
  	echo '--<em>';
  	echo '<a href="user.php?id='.urlencode($subject).'" title="recent posts by '.$row['col_2'].'">'.stripslashes(htmlspecialchars($row['col_2'])).'</a>';
    echo '</em>   ';
    echo date("M dS, Y", $row['submission_date']);
    echo '<p>';
    echo stripslashes(substr($row[col_5],0,350)).' <strong><a href="blog.php?id='.$row['submission_id'].'">Read more >></a></strong>';
    echo '</p>';
    echo "</div>";
    
}
mysql_free_result($result);
?>

<?php

require_once('load.php');

$counter = 0;
if (!mysql_connect($db_host, $db_user, $db_pwd))
    die('<strong style="color:maroon">Sorry, database undergoing maintenance. Please try again later.</strong>');

if (!mysql_select_db($database))
    die("Can't select database");

$result = mysql_query("SELECT * FROM $table WHERE submission_date BETWEEN UNIX_TIMESTAMP(DATE_SUB( CURDATE( ) ,INTERVAL 5 DAY )) and UNIX_TIMESTAMP( ) ORDER BY submission_id DESC")or die(mysql_error());

while($row = mysql_fetch_array($result)){


$counter++;


if(($couter == 3)||($counter==9)){
//ad
}else{
//post
}

}



mysql_free_result($result);
?>

?>

 

 

its manually adding at whats posts it should put an AD..

Archived

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

×
×
  • 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.