With your code it will be something like this:
it if you replace every third
<?php $query="SELECT * FROM table"; $result = mysql_query($query); $i = 1; while ($row = mysql_fetch_assoc($result)) { if ($i % 3 == 0) echo '<div>Реклама</div>'; else echo 'Что-то там из массива'; ++$i } ?>
That is, logically, if you argue, you need to insert advertising in every third block. Accordingly, in the cycle you look at the counter. If the counter turns out to be divided by 3 without a remainder, then we display the advertisement, and if not, then the rest.
If you want to add after each second, as in the example .. then you need to check the remainder of the division by 2
<?php $query="SELECT * FROM table"; $result = mysql_query($query); $i = 1; while ($row = mysql_fetch_assoc($result)) { echo 'Что-то там из массива'; if ($i % 2 == 0) echo '<div>Реклама</div>'; ++$i } ?>
whileletters in your code means? - VladD}in the loop? PS Themysql_functionsmysql_outdated ! Remove them from your code forever. - Visman$post_id = $row['post_id']; echo $post_id;$post_id = $row['post_id']; echo $post_id;justecho $row['post_id'].'<br />';??? Adding "words" at the end - Alexey Shimansky