0

Hope this makes sense, I'll hopefully paint a clear picture.

<?php $rx_event_color = $rx_image_color = '#FF0000';
if ($a['rx_event_exists'] == 1) { $rx_event_color = '#00FF00'; }

if ($a['rx_scanned'] == 1) { $rx_image_color = '#00FF00'; }
else if ($a['rx_scanned'] > 1) { $rx_image_color = '#FFFF00'; }
?>

I don't want the whole background td to change color, only the text inside the td based on the event (data in sql)

if ($a['rx_event_exists'] == 0)
    {
    echo "<tr><td style='background:$rx_event_color'><a href='" 
                    . matry::here_to('new', array('tfilt'=>'WR', 'pfilt'=>$patient->code))
                    . "'>**Rx Event Not Created**</a></td></tr>";
    }

I tried to just change background to color and also tried adding it in a div instead... i figured it should be easier than it's turning out to be.. that's why i'm asking here. Thanks in advance my friends.

3
  • Then why are you using background: in style, use color: instead. Commented Feb 6, 2013 at 20:06
  • instead of dynamically creating the css and injecting it inline (making your code smell)... create a class of each colour in your main css and then just add the class name based on the value you have in the db Commented Feb 6, 2013 at 20:09
  • Thanks Lawrence for responding, I'll keep that in mind. Commented Feb 6, 2013 at 20:21

1 Answer 1

2

You need to move the style attribute to the anchor tag, as the link's styling is controlling the coloring of the text, not the td. Color and background-color can be used interchangeably here, depending on your purposes.

<td><a href='...' style='color:$rx_event_color'>...</a></td>

Alternately, you could use classes:

.notfound a { color: red }

<td class="notfound"><a href="...">...</a></td>
Sign up to request clarification or add additional context in comments.

1 Comment

I'm not sure why I forgot I could attach styles to the link. I completely forgot. Thanks. This worked.

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.