View Full Version : Setting a color class in php...?

11-22-2011, 08:39 PM
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.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<style type="text/css">
body {background-color:ffffff;}




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); ;

while ($i<$num) {

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

<div id= "divone">

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 -->


11-22-2011, 08:54 PM
echo "<A class='emailink' href=mailto:$email>$email </A>."</br>"";

then in your css

a.emaillink {
color: 'red';
color: 'blue';

11-22-2011, 08:54 PM
oh and remove that extra <head> at the top there.

11-22-2011, 09:23 PM
Ahh, perfect! Thanks much. Buffmin