jimleeder123 Posted June 8, 2015 Share Posted June 8, 2015 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? Quote Link to comment https://forums.phpfreaks.com/topic/296704-php-code-in-php-mail/ Share on other sites More sharing options...
Ch0cu3r Posted June 8, 2015 Share Posted June 8, 2015 (edited) 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 June 8, 2015 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/296704-php-code-in-php-mail/#findComment-1513450 Share on other sites More sharing options...
jimleeder123 Posted June 8, 2015 Author Share Posted June 8, 2015 But I've got some stuff required in the message as well that shouldn't be repeated by the for loop. For example a confirmation of order message and customer ID. Would I just put $message .= ..... before the for loop as well as having the for loop like above? Quote Link to comment https://forums.phpfreaks.com/topic/296704-php-code-in-php-mail/#findComment-1513451 Share on other sites More sharing options...
jimleeder123 Posted June 8, 2015 Author Share Posted June 8, 2015 Sorted it. Quote Link to comment https://forums.phpfreaks.com/topic/296704-php-code-in-php-mail/#findComment-1513453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.