Jump to content

PHP Code in PHP Mail?


jimleeder123

Recommended Posts

I am trying to echo out product names onto php mail. I have it in the $message variable, code is below (have cut out a lot of other stuff in there, HTML code is all working fine)

 

$message = '

 

'for($z=0;$z<$h;$z++) {
            
            echo "<tr>";
                echo '<td colspan="18">'.$_SESSION['transferproducts'.$z.''].'</td>';
                echo '<td colspan="2">'.$_SESSION['transferprices'.$z.''].'</td>';
            echo "</tr>";
            
            }'

 

';

 

I'm getting an error on the line where the "for" starts. How can I get it to work correctly?

Link to comment
https://forums.phpfreaks.com/topic/296704-php-code-in-php-mail/
Share on other sites

You want to use the concatenation assignment operator in the for loop not echo.

$message = '';

// generate html
for($z=0;$z<$h;$z++)
{
    $message .= "<tr>";
    $message .= '<td colspan="18">'.$_SESSION['transferproducts'.$z.''].'</td>';
    $message .= '<td colspan="2">'.$_SESSION['transferprices'.$z.''].'</td>';
    $message .= "</tr>";
} 

// output generated html
echo $message;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.