Considering that I'm developing a small simple (photo) ranking, I need a solution to get the first 3 records from the select and apply individual formatting to them, the rest unnecessarily. Note: I do not wish to have to use 2 lops, one way maybe using arrays, correct?
Ihavethefollowingcode:
<?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>