I have data being fetched from MySQLI database. I want to style "Small" so it looks like this:
Here is what my table looks like in PHP. I am unsure how to style specific words from fetched data.
Here's my PHP code:
<?php
$connect = mysqli_connect( 'placeholder','placeholder','placeholder','placeholder');
$sql = "SELECT * FROM databasename";
$result = $connect->query($sql);
if ($result->num_rows > 0) {
while ($row = $result-> fetch_assoc()) {
echo "<tr><td>" . $row["item_name"] . "</td>
<td>" . $row["item_cooldown"] . "</td>
<td>" . $row["item_effect"] . "</td>
<td>" . $row["item_passive"] . "</td>
<td>" . $row["item_cost"] . "</td>
<td>" . $row["item_type"] . "</td>
<td>" . $row["item_size"] . "</td></tr>";
}
}
else {
echo "No Results";
}
$connect->close();
?>
</table>
Any help is very appreciated.
Add a span inside the related cell (the last td tag pair) and make a css class to style it.
You could even have different colours for different data if you make a base class and a modifier class that is either applied using if/else or switch, or just use the data as the class name if they're single-word.
to your last <td> tag change it to:
<td style='backgroundColor:green'> ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.