Home > Mobile >  How can I edit the rows of data in a table using data from a database?
How can I edit the rows of data in a table using data from a database?

Time:05-13

How can I format and style the rows of data in this table where it's displaying my data?

    <table >
    <tr bgcolor=" #b366ff">
                 <th>Game</th>                     
                 <th>Date</th>
                 <th>Score</th>
                 <th>Venue</th>
        </tr>

<?php
$sql = "SELECT * FROM game WHERE username = '{$users}' AND savename = '{$saves}';";
$result = mysqli_query($connection, $sql);
?>
<?php
    while ($row = mysqli_fetch_assoc($result)){
        echo "<tr>";
           echo "<td>".$row['team']."</td>";
           echo "<td>".$row['date']."</td>";
           echo "<td>".$row['score']."</td>";
           echo "<td>".$row['venue']."</td>";
        echo "</tr>";
    }
 ?>

CodePudding user response:

You can do same as you do in normal HTML, you can use

.table tr{
background-color: grey;
}

Also you can use nth child selecter to style the elements.

CodePudding user response:

using a CSS class?

<style>
.tr1{background-color:#333;}
.td1{background-color:#999;}
</style>

echo "<tr >";
echo "<td >".$row['team']."</td>";
  • Related