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

Use slash before double quote

\"

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

OK, addme wass a bit quicker :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.