0

I am trying to add css style to this echo.

// Execute the query
        if($stmt->execute()){
         echo "Record was updated."; 

I have tried

 // Execute the query
        if($stmt->execute()){
         echo "<p style=\"font-color: red;\">Record was updated</p>";

and although there was no errors, the styling was not applied. How might I succeed in this please.

1
  • It's color not font-color. Voting to close as typo. Also, free ProTip™: prefer CSS classes instead of inline styles. Commented Nov 24, 2014 at 4:20

3 Answers 3

2

use

echo '<p style="color: red;">Record was updated</p>';

instead of

echo "<p style=\"font-color: red;\">Record was updated</p>";
Sign up to request clarification or add additional context in comments.

Comments

0

Try this

if($stmt->execute()){
 echo "<p style="color: red;">Record was updated</p>";

As for me i think that The main problem occur because in css if your want to change the color of text/font then we use color:some color; and you font-color:some color; which is wrong, and the other thing is you use \ in your code and I never seen the \ use with css in php, hope this description is enough for you to understand the issue...

If the answer solved your problem the Mark/consider it as your answer, if the answer is helpful for you then vote it as helpful...

2 Comments

Hiya, this may well solve the problem, but it'd be great if you could add some more explanation of how/why this makes it work. Don't forget there are heaps of rank newbies on S/O, and they could learn a thing or two from your expertise... what may be obvious to you may not be so to them.
I went with if($stmt->execute()){ echo '<div class="alert">Record was updated</div>'; .alert {color: red;}
-1

You Can also do it like this

if($stmt->execute())
{
echo '<font color=red>Record was updated</font>';
}

1 Comment

No. That's even more terrible than inline styles. The <font> element is also deprecated in HTML5.

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.