How To Add Css Styles To A Php Code Within A Loop?
I am trying to apply css styles to a php loop: However this does not seem to be applying the css style: .title{ color : red; } I have trie
Solution 1:
We need to use a colon (:
) instead of an equal sign to assign a CSS property value:
.title {
color: red;
}
Solution 2:
<?phpecho"<style>h3.title{ color : red;}</style>"; ?>
Use This Code
Solution 3:
<?php$sql = "SELECT * FROM events LIMIT 10;";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0){
while ($row = mysqli_fetch_assoc($result)){
echo"<p></p> ";
echo"<h3 style='color:#ff0000' class='title'>Event name: </h3>";
echo" ";
echo$row['eventname'];
echo"<p></p> ";
echo"<h3 style='color:#ff0000' class='title'>Event Venue: </h3>";
echo" ";
echo$row['venue'];
echo" <p></p>";
echo"<h3 style='color:#ff0000' class='title'>Event Date: </h3>";
echo" ";
echo$row['date'];
echo" <p></p>";
echo"<b>Event Description: </b>";
echo" ";
echo$row['eventdescription'];
}
}
?>
Post a Comment for "How To Add Css Styles To A Php Code Within A Loop?"