Display name in different colors

I do this :

if($_SESSION['level'] == 1) {
echo "[.$row['date'].]<font color="#ff0000">.$row['username'].</font>.$row['message'].";
}
else {
  echo "[".$row['date']."]".$row['username']."  : ".$row['message'];}
}

But there is no effect, please tell me the error
And here is the chat itself:

<script type="text/javascript">
setTimeout("window.location.reload()",10000);//   5 
</script>
<?php
session_start();
$db = mysql_connect("")or die(mysql_error());
mysql_select_db("")or die(mysql_error());
$result = mysql_query("SELECT * FROM messages ORDER BY id DESC LIMIT 50");
while ($row = mysql_fetch_array($result)){
?>
<html>
<head>
<style>
body{
border-color: #CCCCFF/* */ #CCCCFF/* */ #CCCCFF/* */ #CCCCFF/* */;
border-style:
border-width: 1px/*.*/ 2px/*.*/ 4px/*.*/ 3px/*.*/;
background-color: #CCCCFF;
text-align: center;
}
</style>
</head>
<body>
<div align="left">
<?php
if($_SESSION['level'] == 1) { 
echo $row['date'] . '<font color="#ff0000">' . $row['username'] . '</font>' . $row['message'];
}
else
{
  echo $row['date'] . $row['username'] .  ':' . $row['message'];
}
</div>
</body>
</html>

Answer 1, authority 100%

UPDATE

<?php
  session_start();
  $db = mysql_connect("")or die(mysql_error());
  mysql_select_db("")or die(mysql_error());
  $result = mysql_query("SELECT * FROM messages ORDER BY id DESC LIMIT 50");
?>
<html>
 <head>
  <style>
   body{
    border-color: #CCCCFF/* */ #CCCCFF/* */ #CCCCFF/*   */ #CCCCFF/* */;
    border-style:
    border-width: 1px/*.*/ 2px/*.*/ 4px/*.*/ 3px/*.*/;
    background-color: #CCCCFF;
    text-align: center;
   }
  </style>
  <script type="text/javascript">
    setTimeout("window.location.reload()",10000);//   5 
  </script>
</head>
<body>
 <div align="left">
 <?php
   while ($row = mysql_fetch_array($result)){
    if($_SESSION['level'] == 1) { 
      echo "[".$row['date']."]" . "<font color=\"#ff0000\">" . $row['username'] . "</font>" . " :" . $row['message'];
    }else{
      echo "[".$row['date']."]". $row['username'] .  " :" . $row['message'];
    }
   }
  ?>
 </div>
 </body>
 </html>

Answer 2, authority 100%

Slightly incorrect…Especially if there are many levels. Here it would be better to use the SwitchCase
construct

For the entry itself, try:

echo $row['date'] . '<font color="#ff0000">' . $row['username'] . '</font>' . $row['message'];

If anything…Then you just put other quotes in quotes…That’s not correct…Therefore, they must either be escaped with \ (Example: \”text\”) or single quotes ” (Last the option can only be used with text and HTML and variables in single quotes are not printed.


Answer 3

if($_SESSION['level'] == 1) { 
echo $row['date'] . '<font color="#ff0000">' . $row['username'] . '</font>' . $row['message'];
}
else
{
  echo $row['date'] . $row['username'] .  ':' . $row['message'];
}