We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,629 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

PHP email and styles

Hi guys, sorry if this has been posted before but I am trying to add a color style to my php mail

Here is a snipper of the code that generates an email, it all works fine. The . $efreeformcompanyname . being a value that may or may not be enetered into a field i have.

        $body .= "Company name - " . $exfreeformcompanyname . "\n";
        $body .= "Address - " . $exfreeformaddress . "\n";
        $body .= "Phone number - " . $exfreeformphone . "\n";

Whats I want is for the . $exfreeformcompanyname . bit to be coloured yellow (background colour) if it has a value and as such appears in the sent email.

I have tried a simple span style but a problem occurs with the "" thats already exists in each line.

Any help would be greatly appreciated.

Ian

3
Contributors
3
Replies
50 Minutes
Discussion Span
4 Months Ago
Last Updated
4
Views
snookian
Newbie Poster
1 post since Jan 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Use slash before double quote

\"
addme
Newbie Poster
22 posts since Aug 2012
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0

Have you escaped the double quotes:

if($exfreeformaddress == '') {
    $spanStyle = 'background-color: yellow;';
} else {
    $spanStyle = 'background-color: white;';
}

$body .= "<span style=\"$spanStyle\">Address - " . $exfreeformaddress . "</span>\n";
broj1
Nearly a Posting Virtuoso
1,216 posts since Jan 2011
Reputation Points: 167
Solved Threads: 165
Skill Endorsements: 13

OK, addme wass a bit quicker :-)

broj1
Nearly a Posting Virtuoso
1,216 posts since Jan 2011
Reputation Points: 167
Solved Threads: 165
Skill Endorsements: 13

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0879 seconds using 2.75MB