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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts

    Setting a color class in php...?

    Hello all. Not quite sure how to do this. I am getting comfortable with html & css, but I now added some php to the page. I am displaying php variables, and cannot figure out out how I would make my "email link" a different color than my "website link. I would assume I need to set classes, but they don't seem to work in the "echo" statements. I am hoping that someone would be kind enough to steer me in a direction. Sincerely, Buffmin

    I shortened my code a bit, but you should get the idea.
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <head>
      
    <style type="text/css">
    body {background-color:ffffff;}    
    #divone{width:900px;overflow:auto}
    </style>

    </head>
    <body>

    <?php

    $username
    ="username";
    $password="password";
    $database="database";

    mysql_connect("dbase.perfora.net",$username,$password);
    mysql_select_db($database) or die("unable to select");
    $query "SELECT * FROM `mybiz` WHERE `Type` LIKE '%$name%' ";
    $result=mysql_query($query)or die("Failed Query of " $query);  ;
    $num=mysql_numrows($result);
    mysql_close();

    $i=0;
    while (
    $i<$num) {

    echo 
    "$contact"."</br>"
    echo 
    "<A href=mailto:$email>$email </A>."</br>""
    echo 
    "<a href=$website>$website </A>";

    ?>
    <div id= "divone">

    <?php
    echo "<b>Contact: </b>"."$contact"."</br>"
    echo 
    "<B> Email :</B> <A href=mailto:$email>$email </A><BR>"
    echo 
    "<B> Website :</B> <a href=$website>$website </A><BR>"."</br>";
    ?>

    </div><!-- end of divone -->
    <?
    $i
    ++;
    }

    ?> 
    </body>
    </html>

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    Code:
    echo "<A class='emailink' href=mailto:$email>$email </A>."</br>"";
    then in your css
    Code:
    a.emaillink {
    color: 'red';
    }
    a.emaillink:hover{
    color: 'blue';
    }

  • Users who have thanked DanInMa for this post:

    Buffmin (11-22-2011)

  • #3
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    oh and remove that extra <head> at the top there.

  • #4
    Regular Coder
    Join Date
    Aug 2011
    Posts
    192
    Thanks
    112
    Thanked 0 Times in 0 Posts
    Ahh, perfect! Thanks much. Buffmin


  •  

    Posting Permissions

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