...

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



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

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

then in your css

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

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum