Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-22-2011, 07:39 PM   PM User | #1
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
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>
Buffmin is offline   Reply With Quote
Old 11-22-2011, 07:54 PM   PM User | #2
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
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';
}
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Users who have thanked DanInMa for this post:
Buffmin (11-22-2011)
Old 11-22-2011, 07:54 PM   PM User | #3
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
oh and remove that extra <head> at the top there.
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa is offline   Reply With Quote
Old 11-22-2011, 08:23 PM   PM User | #4
Buffmin
Regular Coder

 
Join Date: Aug 2011
Posts: 192
Thanks: 112
Thanked 0 Times in 0 Posts
Buffmin is an unknown quantity at this point
Ahh, perfect! Thanks much. Buffmin
Buffmin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:04 AM.


Advertisement
Log in to turn off these ads.