I have a code that displays a table in the% list of registered%, and to embellish, the code causes it to display 1 in 1 by alternating the colors between white and gray.
How can I make a repeat structure of ID's
do the same thing?
<?php
$sqln = mysql_query("SELECT * FROM post ORDER BY id DESC LIMIT ".$inicio.",".$max."");
$num = mysql_num_rows($sqln);
for($i = 0; $i < $num; $i++){
$tituloP = @mysql_result($sqln, $i, "titulo");
$n = $i + 1;
$d = $i % 2;
if($d == 0){$cor = "cinza";}else{$cor = "claro";}
print '<tr class='.$cor.'><td> align="center">'.$tituloP.'</td><tr>';
}
?>
I do not know if it makes a difference, but now I'm using while
.
<?php
$sqln = mysqli_query($conn, "SELECT * FROM post ORDER BY id DESC LIMIT ".$inicio.",".$max."");
mysqli_close($conn);
while($num_q = mysqli_fetch_array($sqln)){
$tituloP = $num_q['titulo'];
print '<tr class=' /*COR*/'><td align="center">'.$tituloP.'</td><tr>';
}
?>