1,105,333 Community Members

PHP email and styles

snookian
Newbie Poster
1 post since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

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

Member Avatar
addme
Newbie Poster
22 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Use slash before double quote

\"
Member Avatar
broj1
Posting Virtuoso
1,576 posts since Jan 2011
Reputation Points: 220 [?]
Q&As Helped to Solve: 219 [?]
Skill Endorsements: 21 [?]
Featured
 
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";
Member Avatar
broj1
Posting Virtuoso
1,576 posts since Jan 2011
Reputation Points: 220 [?]
Q&As Helped to Solve: 219 [?]
Skill Endorsements: 21 [?]
Featured
 
0
 

OK, addme wass a bit quicker :-)

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article