1
I created an admin page where I register the book data in the database. I made this html where this data will be shown. the matrix will create this block "cabtitulo" with all the books registered on the administration pages, but I would like it to be visible only 4 of these blocks. so I put down the background-color:green function to check if my code worked, if it worked, I would put a display leaving these other blocks invisible. but all the blocks turn green, not the ones bigger than 3, as I defined.
<div class="cabtitulo"><p>Promoções</p></div>
<?php
$comando="select * from tb_promocao";
$matriz=mysql_query($comando);
$contador = 0;
while ($contador<4) {
while ($linha=mysql_fetch_array($matriz)) {
?>
<article class="livro">
<?php echo '<img src="img/' .$linha["imagempromo"]. '.jpg">'; ?>
<p><span class="titulo"><?php echo $linha["titulopromo"]; ?></span><br>
<span class="precode">R$ <?php echo $linha["precodelivro"]; ?></span><span class="preco">R$ <?php echo $linha["precoparalivro"]; ?></span><br><br></p>
<button>adicionar<i class="fa fa-shopping-cart" aria-hidden="true"></i></button>
<a href="">ver mais</a>
<h2><?php echo $contador; ?></h2>
</article>
<?php
$contador++;
}//close matriz
}//close contador
while ($contador>=3) {
echo '<style> .livro{ background-color:green;}</style>';
}
?>
You are setting all the contents of <article> in green color.
– GustavoAdolfo