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
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;
Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.