Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Smile Value changes color of a a href, while using css

    I'm not sure if this should be under php or html/css, but I think this is the right place.

    I'm listing up a table from a sql request, and for every row it checks if the customer has a comment or not.

    If it has a comment I want the link/text to be blue, else it should stay black as normal.

    Problem is, I use css, and on a href I've set it to be black, and red while hovering over.

    How do I set the text to be blue when the customer has a comment?

    My code:
    PHP Code:
     if($row['comment'] != "") {
        echo 
    "<td>&nbsp;" "<a href=ccustomerdetails.php?details=$rkunde>$kunde</a>" "&nbsp;</td>";
            echo 
    "<td>&nbsp;" "<a href=cverdensdeldetails.php?details=$rverdensdel>$verdensdel</a>" "&nbsp;</td>";
            echo 
    "<td>&nbsp;" "<a href=clanddetails.php?details=$rland>$land</a>" "&nbsp;</td>";
        }
        
        
    //Ellers brukes a href som er blå
        
    else {
        echo 
    "<td>&nbsp;" "<a href=ccustomerdetails.php?details=$rkunde>$kunde</a>" "&nbsp;</td>";
        echo 
    "<td>&nbsp;" "<a href=cverdensdeldetails.php?details=$rverdensdel>$verdensdel</a>" "&nbsp;</td>";
        echo 
    "<td>&nbsp;" "<a href=clanddetails.php?details=$rland>$land</a>" "&nbsp;</td>";
        } 
    I want the first 3 rows to be blue as default, and the other where 'comment' is empty to be black.

    My first attempt was to make a b href and creat a style for it in the css file, but I soon learned that u can only make it a link if it is a href...

    Is it possible to override the .ccs in this case?
    Last edited by Selbyggen; 03-09-2013 at 03:25 PM. Reason: Resolved

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,029
    Thanks
    23
    Thanked 588 Times in 587 Posts
    Use a span for the color change:
    echo "<td>&nbsp;" . "<a href=ccustomerdetails.php?details=$rkunde><span style=\"color:blue\">$kunde</span></a>" . "&nbsp;</td>";

  • Users who have thanked sunfighter for this post:

    Selbyggen (03-09-2013)

  • #3
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    Use a span for the color change:
    echo "<td>&nbsp;" . "<a href=ccustomerdetails.php?details=$rkunde><span style=\"color:blue\">$kunde</span></a>" . "&nbsp;</td>";
    Thank you! This resolved my problem :-)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •