I think its plainly obvious what Im trying to do here.
$message is the message param from wp_mail().
I need this foreach loop to run inside my email to get all the dynamic values from a form.
$tmp = '';
$i = 0;
foreach( $_POST as $key => $value) {
if( substr( $key, 0, 14) == 'course-select-') {
$tmp = '<tr><td>Day number' . $i . ' :</td><td> ' . $value . '</td></tr>';
}
$i++;
};
//construct the email
$message = '
<html>
<head>
<title>Booking Confirmation Part 2</title>
</head>
<body>
<h2>Booking Confirmation Part 2 : ' . $golfersname . '</h2>
<table width="500">
<tr>
<td>Accomodation</td>
<td>' . $accomodation . '</td>
</tr>
<tr>
<td>Singles</td>
<td>' . $singles . '</td>
</tr>
<tr>
<td>Doubles</td>
<td>' . $doubles . '</td>
</tr>
<tr>
<td>Car Type</td>
<td>' . $cartype . '</td>
</tr>
<tr>
<td>Course Details</td>
</tr>
' . $tmp . '
</table>
</body>
</html>
';
Everything breaks from the moment it hits the '. $i = 0;
. What real stupid thing am I missing out on?
The foreach does work as I’ve tested it already in my console.
Thanks