Vote count:
0
this is probably a very basic question, but excuse me, I'm extremely new to PHP.
So I'm trying to generate an email in php using the data collected by javascript and passed to php file in an array.
the array in js looks basically like this
Menu[
item(name,price,multiplier[],ingred),
item(name,price,multiplier[],ingred)
]
the array Menu[] is created dynamically and then passed through the $.ajax call
$.ajax({
url: 'sendEmail.php',
type: 'post',
data: {
emailTo: emailToVal,
tel: telVal,
subject: subjectVal,
message: messageVal,
mijnMenu: JSON.stringify(mijnMenu)},
I need to build a table from the data of the array and send an email. I cannot figure out how to build the rows of the table.
my PHP script is
$body = "<p>Hi,</p>";
$body .= "<p>I have received your mail....</p>;
$body .= "<p>Your menu :</p>";
$body .= "<table style='border: 1px black solid; width: 80%;'><tbody>";
if (isset($_POST["myMenu"])) {
$myMenu = json_decode($_POST["myMenu"]);
foreach($myMenu as $row){
$row = "<tr><td>". $myMenu=>name ."</td><td>". $myMenu=>price."</td><td>". $myMenu=>multiplier[1]. "</td></tr>";
$body .= $row;
}
}
$body .= "</tbody></table>";
$body .= "</body></html>";
Thank you in advance!
asked 1 min ago
how to build a table in html from an array in email in php
Aucun commentaire:
Enregistrer un commentaire