(Translation made with google, sorry.) Need to evaluate this condition which is inside a loop. if true, the </ div>
(which was opened outside) is closed, add a <iframe>
and replay the loop. My problem is that in the "elsif" when closed first div, it goes without displaying the following. The first "if" works perfect.
<?php if($adcount == 8 and $bbb == 8 and $paged == 0) { ?>
</div>
<div id="adds-inner" class="col-md-12 col-sm-12">
<iframe id="my_ad" src="/ad.html" scrolling="no" frameborder="0" style="width:100%;"></iframe>
</div>
<?php } else if($adcount == 8 and $bbb == 8 and $paged > 0) { ?>
<p> this is shown </ p>
</div>
<p> Incredibly, this does not </ p>
<div id="adds-inner" class="col-md-12 col-sm-12">
<iframe id="my_ad" src="/ad2.html" scrolling="no" frameborder="0" style="width:100%;"></iframe>
</div>
<?php } else { ?>
</div>
<?php } ?>
UPDATE
the problem was due to a plugin (infinite scroll) misconfigured, the php code was working perfect. Thank you all for your support and sorry for the mistake.
I don't think the problem is what you think it is. As @JoshfromQaribou said in this comment we can mode the </div>
out of the if else statement because it will be needed regardless of the logic. But the problem seems to be your else if statement is never being reached. I can't tell without seeing the full code but if you are only getting the </div>
and not the rest then that code is never being reached and it is going straight to the else.
Try this code:
</div> <?php #<----- See how I moved this out of each below. ?>
<?php if($adcount == 8 and $bbb == 8 and $paged == 0) { ?>
<br />First Condition<br />
<div id="adds-inner" class="col-md-12 col-sm-12">
<iframe id="my_ad" src="/ad.html" scrolling="no" frameborder="0" style="width:100%;"></iframe>
</div>
<?php } else if($adcount == 8 and $bbb == 8 and $paged > 0) { ?>
<br />Second Condition<br />
<div id="adds-inner" class="col-md-12 col-sm-12">
<iframe id="my_ad" src="/ad2.html" scrolling="no" frameborder="0" style="width:100%;"></iframe>
</div>
<?php } else { ?>
<br />No conditions met.<br />
<?php } ?>
Done with conditions.
I bet you get "No conditions met.". It could be because $paged
is less than 0 or one(or both) of your other variable isn't equal to 8.
Update
With your updated code I can see that your else if
condition is being met. It is really weird that this only displays some of your HTML. I am not sure it will do anything for you but try this refactored code. Simplifying the code may make the problem more obvious.
</div>
<?php if($adcount == 8 && $bbb == 8) { ?>
<div id="adds-inner" class="col-md-12 col-sm-12">
<iframe id="my_ad" src="<?php if($paged==0) echo "/ad.html" else if($paged > 0) echo "/ad2.html" ?>" scrolling="no" frameborder="0" style="width:100%;"></iframe>
</div>
<?php } ?>
Just copy and past this where your code was. Don't make any changes.
Have you tried to echo
your html instead of just having it there. I find that sometimes using html like that gives me bugs so i usually echo and wrap the html in single quotes.