Is This Really Simple PHP Code Correct?

by Banned 3 replies
4
<?php $post_counter=0; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>

<?php
$post_counter++;
if ($post_counter == 2 || $post_counter == 4) { ?>

<div style="float:right; margin-right:25px;">
adsense code is placed here
</div>
<div class="clear"></div">
<?php } ?>

<?php endwhile; ?>
<?php endif; ?>



It works fine when I have only $post_counter == 2

But when I add the ... || $post_counter == 4
It works, but the footer becomes distorted. The footer usually has no background, but when I add that part, it becomes part of the main container with the white background.

I'm confused could somebody help me?

Thank you.
#programming #code #correct #php #simple
  • has nothing to do with the php code but most likely with your CSS coding..
    • [ 1 ] Thanks
  • Banned
    FIXED

    I removed the

    <div class="clear"></div">

    and it fixed it.
    • [ 1 ] Thanks
  • The problem might be from the div

Next Topics on Trending Feed