Jump to content
Stef's Coding Community
Scotty13

echo out Happy Anniversary! in red

Recommended Posts

I’m building a member page and when it reaches there anniversary date. I want “Happy Anniversary” to display in red. Currently it displays in black.

 

Code below…

 

<?php

/*$sDayMSG = "";

$today = date("Y-m-d");// today would be 2010-10-09

// Query database for user data

$seniority = $row['seniority'];

if ($today == $seniority) {// Evaluate if they match today

$sDayMSG = "Happy Anniversary!";

 

}*/

 

// Now convert for display like normal here

$seniority = strftime("%b. %d, %Y", strtotime($seniority));

 

//echo $sDayMSG; // Wherever you need it on the page

?>

Share this post


Link to post
Share on other sites

Look at the source code of the page that displays this text and see what the codes around it are - then change to color to the appropriate tags to red.

Share this post


Link to post
Share on other sites

Andrea's correct -- this would be a HTML/CSS change, not a PHP change. For example, you might need to do something like this:

 

<div class="red"><?php echo $sDayMSG; ?></div>

 

where the .class has the text color set to red.

Share this post


Link to post
Share on other sites

If you want to do it in-line with the PHP, which isn't generally good practice, you can change

 

$sDayMSG = "Happy Anniversary!";

 

to

 

$sDayMSG = '<span style="color: #FF0000;">Happy Anniversary!</span>';

 

Otherwise do what these other folks are talking about

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...