1
Considering that I am developing a small ranking of simple classification (photo), I need a solution to take the first 3 records of select and apply an individual formatting to them, the others without need. Note: I do not wish to have to use 2 Ops, one way may be using arrays, correct?
I have the following code:
<?php
$selPlacares = $conn->prepare("SELECT * FROM jogadores j LEFT JOIN placares p ON p.pla_jog_id = j.jog_id GROUP BY j.jog_id ORDER BY p.pla_cartas DESC, p.pla_tempo ASC, j.jog_nome ASC");
$selPlacares->execute();
$cont = $selPlacares->rowCount(); ?>
<table border="0" align="left" width="70" cellpadding="5" cellspacing="5">
<tr style="background: #58589E;">
<td>Pos.</td>
</tr>
<tr style="background: #E7BD40;">
<td>1º</td>
</tr>
<tr style="background: #c9c9c9; color: #000;">
<td>2º</td>
</tr>
<tr style="background: #623825;">
<td>3º</td>
</tr>
<?php for($s = 4; $s <= $cont; $s++): ?>
<tr>
<td><?php echo $s."°"; ?></td>
</tr>
<?php endfor; ?>
</table>
<table border="0" align="left" width="85%" cellpadding="5" cellspacing="5">
<tr style="background: #58589E;">
<td>Nome do jogador</td>
<td>Quant. Cartas</td>
<td>Tempo</td>
</tr>
<?php while($rowPlacares = $selPlacares->fetch(PDO::FETCH_OBJ)): ?>
<tr>
<td><?php echo $rowPlacares->jog_nome; ?></td>
<td><?php echo $rowPlacares->pla_cartas; ?></td>
<td><?php echo $rowPlacares->pla_tempo; ?></td>
</tr>
<?php endwhile; ?>
</table>
Actually, much more practical, I will use this form because it is more practical, however, the first answer exclaimed how we can do using PHP. Thank you for your reply.
– Tiago Boeing