How do I put a Static Advertising block after the first result of a while in PHP?
I leave below my while:
while($fetch = $get->fetch()){
}
Type this:
Just use a counter , that is when it is 2 iterating while will do what you want (in this case it will start publicidade
).
And you use continue
, to jump to the next iteration.
<?php
$contador = 0;
while($fetch = $get->fetch()){
$contador++;
echo "conteudo";
if($contador == 2){
//Resultado estatico na segunda vez do while
echo "publicidade";
}
}
You can add a control variable. It would look something like
$publi = true;
while($fetch = $get->fetch()){
echo 'conteudo';
if(publi){
echo 'publicidade';
publi = false;
}
}