Hi,
I have a form with an array. kidname, age and lesson.
http://jawaweb.com/e1.jpg
I fill up with 2 kids to join, when i click on send, there are 2 email sent to same addresses and all the informations going to mysql database. confirmation pagina shows.
http://jawaweb.com/e2.jpg
When i view a joinform, data comes from mysql using 2 colomn
http://jawaweb.com/e3.jpg
if i fill up with 3 kids, it will send 3 email ect.
how to send all kiddata to 1 email?
perhaps someone can help me?
thanks in advance.
<body>
<?php
//Database connection
require "db.php";
// Data Form
if (isset($_POST["naam"])) $name = $_POST["name"];
if (isset($_POST["address"])) $address = $_POST["address"];
if (isset($_POST["zip"])) $zip = $_POST["zip"];
if (isset($_POST["city"])) $city = $_POST["city"];
if (isset($_POST["phone"])) $phone = $_POST["phone"];
if (isset($_POST["email"])) $email = $_POST["email"];
foreach($_POST['kidname'] as $row => $value1)
{
$kidname = mysql_real_escape_string($value1);
$age = mysql_real_escape_string($_POST['age'][$row]);
$lesson = mysql_real_escape_string($_POST['lesson'][$row]);
$kiddata = $kidname . " - " . $age . " - " . $lesson;
//echo $name.$address.$zip.$city.$phone.$email.$kiddata.
$sql = "INSERT INTO aanmelding VALUES (NULL, '$name', '$address', '$zip', '$city', '$phone', '$email', '$kiddata')";
$res = mysql_query($sql);
if ($res){
}
$ord = mysql_query("SELECT aanmldid FROM aanmelding ORDER BY aanmldid DESC LIMIT 1");
$row = mysql_fetch_row($ord);
if (!empty($email)){
$ontvanger = $email;
}
$to = EMAIL;
$subject = "Request";
$datas = "Dear Sir/Madam $name, <br><br>
Hereby the corfirmation of your request.<br>
We have inserted your data in our database (please check it up): <br>
<br>
<table>
<tr><td width=190>No</td><td>:</td><td>$row[0]</td></tr>
<tr><td>Name</td><td>:</td><td>$name</td></tr>
<tr><td>Address</td><td>:</td><td>$address</td></tr>
<tr><td>Zip</td><td>:</td><td>$zip</td></tr>
<tr><td>City</td><td>:</td><td>$city</td></tr>
<tr><td>Phone</td><td>:</td><td>$phone</td></tr>
<tr><td>E-Mail</td><td>:</td><td>$email</td></tr>
<tr><td>Kind data</td><td>:</td><td>$kinddata</td></tr>
</table>
";
$header = "From: ".$name." <".$email.">\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "Reply-To: ".$name." <".$email.">\r\n";
@mail($to, $subject, $datas, $header);
}
?>
<h2> Thank's, we wil answer your request soon. You have sent:</h2><br>
<fieldset><legend><font color="#FE9A2E"><b>Request</b></font></legend>
<table>
<tr>
<td width="190">No</td><td>:</td>
<td><?php
$ord = mysql_query("SELECT aanmldid FROM aanmelding ORDER BY aanmldid DESC LIMIT 1");
$row = mysql_fetch_row($ord);
echo $row[0];
?></td></tr>
<tr><td>Name</td><td>:</td><td><?php echo $name;?></td></tr>
<tr><td>Address</td><td>:</td><td><?php echo $address;?></td></tr>
<tr><td>Zip</td><td>:</td><td><?php echo $zip;?></td></tr>
<tr><td>City</td><td>:</td><td><?php echo $city;?></td></tr>
<tr><td>Phone</td><td>:</td><td><?php echo $phone;?></td></tr>
<tr><td>E-Mail</td><td>:</td><td><?php echo $email;?></td></tr>
</table>
<br>
<table class="tabel" cellpadding="4" cellspacing="0">
<tr bgcolor="#e5e5e5">
<td width="100">
Kidname</td>
<td width="100">
Age</td>
<td width="150">
Lesson</td>
</tr>
<tr>
<td width="100">
<?php
$kidname = isset($_POST["kidname"]) ? $_POST["kidname"] : array();
foreach($kidname as $value1) echo $value1.'<br />';
?>
</td>
<td width="100">
<?php
$age = isset($_POST["age"]) ? $_POST["age"] : array();
foreach($age as $value2) echo $value2.'<br />';
?>
</td>
<td width="150">
<?php
$lesson = isset($_POST["lesson"]) ? $_POST["lesson"] : array();
foreach($lesson as $value3) echo $value3.'<br />';
?>
</td>
</tr>
</table>
</fieldset><br><br><br>
<fieldset><legend><font color="blue"><b>D A T A B A S E</b></font></legend>
<br>
<?php
//select tabel
$sql = "SELECT * FROM aanmelding ORDER BY aanmldid DESC";
$res = mysql_query($sql);
?>
<table class="tabel" cellpadding="4" cellspacing="0">
<tr bgcolor="#e5e5e5">
<td><span>ID</span></td>
<td><span>Name</span></td>
<td><span>Address</span></td>
<td><span>Zip</span></td>
<td><span>City</span></td>
<td><span>Phone</span></td>
<td><span>E-mail</span></td>
<td><span>Kid data</span></td>
</tr>
<?php
//display data from selected tabel
while ($row = mysql_fetch_row($res)){
echo "<tr>
<td valign=top><span>$row[0]</span></td>
<td valign=top><span>$row[1]</span></td>
<td valign=top><span>$row[2]</span></td>
<td valign=top><span>$row[3]</span></td>
<td valign=top><span>$row[4]</span></td>
<td valign=top><span>$row[5]</span></td>
<td valign=top><span>$row[6]</span></td>
<td valign=top><span>$row[7]</span></td>
</tr>";
}
?>
</table></fieldset>
</body>
</html>