Neilos wrote:I don't fully understand your question.
Am I right in thinking that you just want to create a list of questions and answers to send in an email to the user. If so then what I would do is;
Well, it is so: The user comes to the web page, he fills out his personal data, then there is a part with "Bookings", here are some Questions like:
"What is your food preference?"
He can then answer (mutliple checkbox):
1. Vegetarian
2. Kosher
3. No fish
Then there is e.g. another question:
"How old are you?"
Answers:
1. 20-30
2. 31-40
3. 40+
So, he now clicks "Vegetarian" and "31-40" and then on the button "Submit". The form is submitted, the user lands on a "Confirmation page" where his data is shown incl. his Bookings.
At this moment, an email Confirmation is sent to the user, which also contains his data, but NOT his bookings, I can manage to show 1 booking, but not all of them. Since, to show all of them, I would have to use some kind of loop (similar to what is used when the bookings are shown in the Webpage Confirmation.
But I can't "pack" this whole loop into a $something, which is NEEDED to use with replace and a keyword like {something} in the html mail body. I can't put the loop code DIRECTLY in the html mail body, because this is already "inside" a $hmtlBody.
Here below you have the code to what I mean:
The Confirmation Webpage where the Qustions/Answers booked by the user are shown correctly:
Code: Select all
<tr class="bg-text">
<td align="right">Street</td>
<td align="left">
<td align="left"><?php echo mysql_result($quser, 0,"ad_street"); ?> </tr>
<tr class="bg-text">
<?php
$question = mysql_query("SELECT * FROM question WHERE invite_in_id=".$in_id." ORDER BY qu_order");
if(mysql_num_rows($question) > 0){
?>
<tr class="bg-text">
<td align="right"> </td>
<td align="right"> </td>
<td align="right"> </td>
</tr>
<?php
}
?>
<?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>
<?php }else{?>
<tr class='bg-text'>
<td align="right">Answers</td>
<td align="left"> </td>
<td align="left"><?php echo $row["qu_text"]; ?></td>
</tr>
<?php
}
if($row["qu_type"] == 0 || $row["qu_type"] == 1){
$answers = mysql_query("SELECT * FROM answer WHERE question_qu_id=".$row["qu_id"]." AND addressbook_ad_id=".$ad_id);
if(mysql_num_rows($answers) > 0){
$antext = mysql_result($answers, 0,"an_text");
?>
<tr class='bg-text'>
<td align="right"></td>
<td align="left"> </td>
<td align="left"><?php if($antext == ""){echo "No answer"; }else{ echo $antext; } ?></td>
</tr>
<?php
}else{
?>
<tr class='bg-text'>
<td align="right"></td>
<td align="left"> </td>
<td align="left">No answer</td>
</tr>
<?php
}
}
if($row["qu_type"] == 2){
$answers = mysql_query("SELECT * FROM answer WHERE question_qu_id=".$row["qu_id"]." AND addressbook_ad_id=".$ad_id);
if(mysql_num_rows($answers) > 0){
?>
<?php while($ddrow = mysql_fetch_array($answers, MYSQL_ASSOC)){ ?>
<tr class='bg-text'>
<td align="right"></td>
<td align="left"> </td>
<td align="left"><?php echo $ddrow["an_text"]; ?></td>
</tr>
<?php } ?>
<?php
}else{
?>
<tr class='bg-text'>
<td align="right"></td>
<td align="left"> </td>
<td align="left">No answer</td>
</tr>
<?php
}
}
}
?>
And here is where the html mail is created:
Code: Select all
$htmlBody = '
<html>
<head>
<title>www.xxxxxxxxxxxxx</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
....
<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>
<tr class="text">
<td align="left" width="20%">Last name</td>
<td align="left" width="5%">:</td>
<td align="left"><strong>{last} </strong></td> </tr>
<tr class="text">
<td align="left" width="20%">Company</td>
<td align="left" width="5%">:</td>
<td align="left"><strong>{firma}</strong></td> </tr>';
Now, under "Company" I need a keyword like {bookings} which will show the list of Questions with the answer that the user chose when he filled the form, like:
Q1: Answer 1
Q2: Answer 2
...
The html mail loop is generated with this code:
Code: Select all
/* ########################## MAILLOOP ############################ */
$emailid = $st_id;
...
$htmlBody= str_replace('{first}', $firstname, $htmlBody);
$htmlBody= str_replace('{last}', $name, $htmlBody);
$htmlBody= str_replace('{firma}', $company, $htmlBody);
I need here replace statement for the whole loop which pulls out the questions and answers which the user chose. I need to "pack" this into a $bookings, which then I would use here:
Code: Select all
$htmlBody= str_replace('{bookings}', $bookings, $htmlBody);
I would then put the keyword {bookings} in the code above where all keywords are used, so that the bookings may show.
Sorry if I am failing to describe this correctly. I am fairly good with editing a lot of php code, but not writing myself much.
I am trying.