Loop inside Mail htmlyBody
Posted: Mon Jan 03, 2011 9:20 am
Hello,
Sorry if this has been answered somewhere, my head is just about to explode and I can't think straight anymore ...
I have a loop, which brings up Multiple Questions and Answers on the webpage just fine. The process then goes on by sending an email confirmation to the user of his entered data.
While fields like Name, Company, etc. are shown just fine in the email (html mail) I can't figure out how to show the multiple questions and answers in the email, and my problems lies with the fact that in the htmlBody of the mail I use replace, to replace keywords like {name} with the content of $name.
But since Questions and answers are multiple, then I would have to replace a keyword like {questions} with a php loop - and that doesn't work in the htmlBody.
here is an example of the loop on the webpage:
Now, here is an example of the htmlBody:
The keyword {first} of course pulls the content from here:
Is it possible to "pack" a whole loop in something like $loop? Because then of course I would just do "$htmlBody= str_replace('{loop}', $loop, $htmlBody);"
But this doesn't seem to work.
Basically, on the webpage the Questions and Answers are shown just fine, like:
Question 1: Answer 1
Question 2: Answer a, b, c (mutliple checkbox)
Question 3: Answer xyz
And I would just like to have this whole part to show up exactly like that in the email.
Can anyone help me here?
Sorry for my ignorance.
Sorry if this has been answered somewhere, my head is just about to explode and I can't think straight anymore ...
I have a loop, which brings up Multiple Questions and Answers on the webpage just fine. The process then goes on by sending an email confirmation to the user of his entered data.
While fields like Name, Company, etc. are shown just fine in the email (html mail) I can't figure out how to show the multiple questions and answers in the email, and my problems lies with the fact that in the htmlBody of the mail I use replace, to replace keywords like {name} with the content of $name.
But since Questions and answers are multiple, then I would have to replace a keyword like {questions} with a php loop - and that doesn't work in the htmlBody.
here is an example of the loop on the webpage:
Code: Select all
<?php while($row = mysql_fetch_array($question, MYSQL_ASSOC)) { ?>
<?php if($row["qu_type"] == 3){ ?>
<tr class='bg-text'>
<td align="right"> </td>
<td align="left"> </td>
<td align="left"><?php echo $row["qu_text"]; ?></td>
</tr>Now, here is an example of the htmlBody:
Code: Select all
<tr class="text">
<td align="left" width="20%">First Name</td>
<td align="left" width="5%">:</td>
<td align="left"><strong>{first}</strong></td> </tr>Code: Select all
$htmlBody= str_replace('{first}', $firstname, $htmlBody);But this doesn't seem to work.
Basically, on the webpage the Questions and Answers are shown just fine, like:
Question 1: Answer 1
Question 2: Answer a, b, c (mutliple checkbox)
Question 3: Answer xyz
And I would just like to have this whole part to show up exactly like that in the email.
Can anyone help me here?
Sorry for my ignorance.