I have an HTML table design, where the first horizontal column is always gray and the second is white, then the same process was repeated, gray and then white and so on, which is represented as follows:
The class
b-color
represents the color gray<tr class="b-color"></tr>
The class
bg-color
represents the color white<tr class="bg-color"></tr>
From the following query:
<?php
$stmt = $con->prepare("SELECT id_best_teams,rank,country,total_points,previous_points FROM best_teams WHERE active=? order by id_best_teams ASC LIMIT 3");
$stmt->bind_param("i",$active);
$active = "1";
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows>0) {
$stmt->bind_result($id_best_teams, $rank, $country, $total_points, $previous_points);
while ($stmt->fetch()) {
echo '<tr class="b-color">
<td class="rank">'.$rank.'.</td>
<td class="country">'.$country.'</td>
<td class="t-points">'.$total_points.'</td>
<td class="t-points p-points">'.$previous_points.'</td>
</tr>';
}
} else {
}
$stmt->close();
?>
How can I get the same HTML table layout to be preserved i.e. the colors?
How to print the results in the following way already specified above, the first horizontal column that is always gray and the second is white, then the same process is repeated, gray and then white and so on as the image showed.
You can use a counter and add the appropriate class depending on the value of the counter. I leave you an example: