Change color of a row in an html table depending on a value

0

I am trying to change the color of a row of my html table, depending on the value of a cell, but when I update the page I observe the colors that I put them, it takes about 1 second. and these colors disappear, I'm using Chrome.

What could be happening?

PHP / HTML:

<tbody>
                            <?php
                            $array_causa_colores = array(
                                'Por determinar' => 'green',
                                'Problema con el enlace de proveedor' => 'yellow'
                            );
                            ?>
                        <?php while($row = $resultado->fetch_array(MYSQLI_ASSOC)) { ?>


                            <tr class= "<?php echo $array_causa_colores[$row['causa']];?>"> 
                                <td><?php echo $row['id']; ?></td>
                                <td><?php echo $row['alcance']; ?></td>
                                <td><?php echo $row['tecnologia']; ?></td>
                                <td><?php echo $row['serv_afectados']; ?></td>
                                <td><?php echo $row['zona']; ?></td>
                                <td><?php echo $row['inicio']; ?></td>
                                <td><?php echo $row['fin']; ?></td>
                                <td><?php echo $row['ticket']; ?></td>
                                <td><?php echo $row['causa']; ?></td>
                                <td><?php echo $row['solicitud']; ?></td>
                                <td><a href="modificar.php?id=<?php echo $row['id']; ?>"><span class="glyphicon glyphicon-pencil"></span></a></td>
                                <td><a href="#" data-href="eliminar.php?id=<?php echo $row['id']; ?>" data-toggle="modal" data-target="#confirm-delete"><span class="glyphicon glyphicon-trash"></span></a></td>
                            </tr>

CSS:

.green{background-color: green;}
.yellow{background-color: yellow;}
    
asked by Daniel 23.09.2018 в 09:53
source

1 answer

0

In Chrome you can use the Ctrl-shift-I keys to see the HTML elements and so on. Access the HTML tr tag with the arrow and see if you have lost the green or yellow class, or if there is a style with background-color that rules the class. The code is correct, there is some class, javascript or style that overwrites the code of PHP.

    
answered by 23.09.2018 в 18:22