0

I used the font color red, but in my page it showing green color.

<?php

include('connect-db.php');

$result = mysql_query("SELECT * FROM players") or die(mysql_error());

while($row = mysql_fetch_array( $result )) {     
    echo '<font color=\"red\">';              
    echo $row['firstname']  ;
    echo '</font>';
    echo ':';
    echo $row['lastname'] ;
    echo '<br><br>';
} 

?>
3
  • 1
    Why don't you use CSS for this? Don't rely upon such HTML attributes. They have already been deprecated or about to be deprecated. Always use CSS. Commented Jun 9, 2012 at 4:12
  • 1
    You also don't need all those echos, one for each line. You could use a HEREDOC, for instance. Commented Jun 9, 2012 at 4:13
  • If you don't need a separate CSS class right now then replace your color attribute in your <font> tag with a style attribute something like this <font style='color:red'></font>. Commented Jun 9, 2012 at 4:26

1 Answer 1

2
<?php

include('connect-db.php');

$result = mysql_query("SELECT * FROM players") or die(mysql_error());

while($row = mysql_fetch_array( $result )) {     
echo '<span style=\"color:red;\">';              
echo $row['firstname']  ;
echo '</span>';
echo ':';
echo $row['lastname'] ;
echo '<br><br>';
} 

?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.