I have a site who are gonna show which games are running. They are in a table and each game have a th. I wants to make them different from each other. Ex if the game are HS U11A then it should be th class=blue
Current script:
$sql = "SELECT kamp, kategori, raekke, tid, loebenr FROM turneringsinfo WHERE loebenr LIKE '1' ORDER BY loebenr ASC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<th>" . $row["kategori"]. ' ' . $row["raekke"]. "</th>";
}
echo "</table>";
} else {
echo "0 results";
}
Outputs:
<table>
<th>HS U11 A</th>
<th>DS U13 B</th>
<th>HS U17 A</th>
<th>HS SEN A</th>
<th>HS SEN D</th>
<th>HS U11 B</th>
<th>HS U19 A</th>
Wanted output:
<table>
<th class="red">HS U11 A</th>
<th class="green">DS U13 B</th>
<th class="blue">HS U17 A</th>
<th>HS SEN A</th>
<th>HS SEN D</th>
<th>HS U11 B</th>
<th>HS U19 A</th>
What I've found that I think could give help me in this case
$setning = "You should eat fruits, vegetables, and fiber every day.";
$gammeltord = array("fruits", "vegetables", "fiber");
$nyttord = array("pizza", "beer", "ice cream");
$nysetning = str_replace($gammeltord, $nyttord, $setning);
echo "$nysetning"
The site is also live so you can see the visuals here: http://turneringsportalen.no/beta/tidslinje.php
Hope i have explained myself and are looking forward for your help :)
Regards Øystein