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? 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 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; 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? 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. 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
Archived
This topic is now archived and is closed to further replies.