Home > other >  How to style echoed text?
How to style echoed text?

Time:03-20

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>");


    }
} 
}

CodePudding user response:

1- create a class in your css (i.e: myClass)

2- use echo like this: echo 'User: <span >'.$row['user'].'</span></br>' ;

Edited:

html characters in php are like string! so you may concat them all like this:

echo '</br> 
      <div >
        User: '.$row['user']
        .'</br> 
        Time: '.$row['time']
        .'</br>
        Message: '.$row['content']
      .'</div> </br>';
  • Related