2
I have the following code.
<table style="width:100%;">
<thead>
<tr>
<th scope='col'> Nº Comanda </th>
<th scope='col'> Produto </th>
<th scope='col'> Quantidade </th>
<th scope='col'> V. Unitário </th>
<th scope='col'> V. Total </th>
<th scope='col'> Registrado Por: </th>
<th scope='col'> Data & Hora: </th>
</tr>
</thead>
<tfoot>
<?php
$buscarucomanda=mysql_query("SELECT cont_estoques_cadp.descricao,
cadastro_geral.nome_com,
cadastro_geral.id,
comanda.status,
comanda.quantidade,
comanda.valorUnit,
comanda.valortt,
comanda.data_op,
comanda.id_user,
comanda.num_comanda
FROM
cadastro_geral
JOIN
comanda
JOIN
cont_estoques_cadp
ON
comanda.id_user = cadastro_geral.id
and
cont_estoques_cadp.id=comanda.id_produto
WHERE comanda.status='0'
order by comanda.num_comanda ASC");
if(mysql_num_rows($buscarucomanda) == 0){
echo "<tr>
<td colspan='6'>
<center>
Não foi possível localizar os produtos registrados. <br>
Consulte seu supervisor para mais informações!
</center>
</td>
</tr>";
}else{
while($linha=mysql_fetch_array($buscarucomanda)){
?>
<tr>
<td><?php echo $linha['num_comanda'];?></td>
<td><?php echo utf8_encode($linha['descricao']);?></td>
<td><?php echo $linha['quantidade'];?></td>
<td><?php echo $linha['valorUnit'];?></td>
<td><?php echo $linha['valortt'];?></td>
<td><?php echo utf8_encode($linha['nome_com']);?></td>
<td><?php echo date('d/m/Y',strtotime($linha['data_op']));?> às <?php echo date('H:i',strtotime($linha['data_op']));?></td>
</tr>
<?php
}
}
?>
</tfoot>
</table>
which returns the following result.
However, I am in order to customize my table, giving alternate colors to tr
. But I wanted to do it differently:
I wanted to give different colors of color Nº Comanda
, and the end result would be more or less like this:
How to proceed in this case?
Each of these "Nº Comanda" would have a different color? You have already decided which number gets which color?
– Sergio
What is the condition of the record to change the color, because you mention the column, but in your example are column-specific records?
– MagicHat
The condition to change the color would be: Each 'Nº Comanda' different, the table would change the color. I have thought about defining a color for each number in a static way, however this command number is currently between 0 and 200, but can change in the future to 0 and 400 or 0 and 1000 and I would like to leave something dynamic only in the result display.
– WebCraft
Do you mean that the command 1 has a color 2 has another and so on? Colors cannot be repeated?
– MagicHat
It could be one color. like Yellow. The same is in this image: https://i.stack.Imgur.com/Akdwb.png - But if 1 has a color, 2 would not have, 3 would have the same color as 1, but 4 would have the same color as 2. Understand?
– WebCraft
Ah, you want to create a zebra effect every time the number changes is that?
– Sergio
Exactly.....
– WebCraft