'How to style echoed text?
I am trying to style the user, time and content. they only appear once the user has entered a comment into the website and so I cannot use <p> tags with inline CSS. any suggestions?
if ($result->num_rows != 0 )
{
$row;
while($row = $result->fetch_assoc())
{
echo("</br>");
echo("User: ".$row['user']."</br>");
echo("Time: ".$row['time']."</br>");
echo("Message: ".$row['content']."</br>");
}
}
}
Solution 1:[1]
1- create a class in your css (i.e: myClass)
2- use echo like this:
echo 'User: <span class="myClass">'.$row['user'].'</span></br>' ;
Edited:
html characters in php are like string! so you may concat them all like this:
echo '</br>
<div class="myClass">
User: '.$row['user']
.'</br>
Time: '.$row['time']
.'</br>
Message: '.$row['content']
.'</div> </br>';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
