Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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


                }
            } 
          }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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>';
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading