HTML mail met meerdere database records
Ik ben bezig met een HTML mail, waarin (dagelijks) meerdere records van een database in geplaatst moeten worden. Het versturen van de HTML mail is an sich geen probleem, echter wordt voor elke record een nieuwe mail gestuurd. Dat is gezien het onderstaande script niet geheel onlogisch, echter weet ik niet hoe ik alles binnen één mail kan houden. Kan iemand mij helpen??
Groet, Marco
----
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?
mysql_connect("db97.xxxxx","xxxx","xxxx");
mysql_select_db("xxxx");
$queryofferte1="SELECT DATE_FORMAT(sluitingsdatum, '%d-%m-%Y')
AS datumNL, datum, vertrek, aankomst, type, status, offerteid, personen from offerte WHERE sluitingsdatum = CURDATE() AND status ='open'";
$resultofferte1=mysql_db_query("xxx",$queryofferte1);
while($objectofferte1=mysql_fetch_object($resultofferte1))
{
$message = '
<html>
<head>
<title>xxxx</title>
</head>
<body>
<p><img src="http://xxx.jpg" width="800" height="85" /></p>
<p> </p>
<table width="776" border="1">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>'.$objectofferte1->vertrek.'</td>
<td>'.$objectofferte1->aankomst.'</td>
<td>'.$objectofferte1->type.'</td>
<td>'.$objectofferte1->personen.'</td>
<td>'.$objectofferte1->datum.'</td>
<td>'.$objectofferte1->datumNL.'</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>
';
$to = 'xxx';
$onderwerp = "Proef mailing";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "xxx";
$subject = 'proef mailing';
mail($to, $subject, $message, $headers);
}
?>
mysql_connect("db97.xxxxx","xxxx","xxxx");
mysql_select_db("xxxx");
$queryofferte1="SELECT DATE_FORMAT(sluitingsdatum, '%d-%m-%Y')
AS datumNL, datum, vertrek, aankomst, type, status, offerteid, personen from offerte WHERE sluitingsdatum = CURDATE() AND status ='open'";
$resultofferte1=mysql_db_query("xxx",$queryofferte1);
while($objectofferte1=mysql_fetch_object($resultofferte1))
{
$message = '
<html>
<head>
<title>xxxx</title>
</head>
<body>
<p><img src="http://xxx.jpg" width="800" height="85" /></p>
<p> </p>
<table width="776" border="1">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>'.$objectofferte1->vertrek.'</td>
<td>'.$objectofferte1->aankomst.'</td>
<td>'.$objectofferte1->type.'</td>
<td>'.$objectofferte1->personen.'</td>
<td>'.$objectofferte1->datum.'</td>
<td>'.$objectofferte1->datumNL.'</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>
';
$to = 'xxx';
$onderwerp = "Proef mailing";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "xxx";
$subject = 'proef mailing';
mail($to, $subject, $message, $headers);
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Marco
hierrond dus:
<tr>
<td>'.$objectofferte1->vertrek.'</td>
<td>'.$objectofferte1->aankomst.'</td>
<td>'.$objectofferte1->type.'</td>
<td>'.$objectofferte1->personen.'</td>
<td>'.$objectofferte1->datum.'</td>
<td>'.$objectofferte1->datumNL.'</td>
</tr>
mail functie buiten de while-loop houden...
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?
mysql_connect("db97.xxxxx","xxxx","xxxx");
mysql_select_db("xxxx");
$queryofferte1="SELECT DATE_FORMAT(sluitingsdatum, '%d-%m-%Y')
AS datumNL, datum, vertrek, aankomst, type, status, offerteid, personen from offerte WHERE sluitingsdatum = CURDATE() AND status ='open'";
$resultofferte1=mysql_db_query("xxx",$queryofferte1);
$message = '<html>
<head>
<title>xxxx</title>
</head>
<body>
<p><img src="http://xxx.jpg" width="800" height="85" /></p>
<p> </p>
<table width="776" border="1">';
while($objectofferte1=mysql_fetch_object($resultofferte1))
{
$message .= '
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>'.$objectofferte1->vertrek.'</td>
<td>'.$objectofferte1->aankomst.'</td>
<td>'.$objectofferte1->type.'</td>
<td>'.$objectofferte1->personen.'</td>
<td>'.$objectofferte1->datum.'</td>
<td>'.$objectofferte1->datumNL.'</td>
</tr>';
}
$message .=' <tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>';
$to = 'xxx';
$onderwerp = "Proef mailing";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "xxx";
$subject = 'proef mailing';
mail($to, $subject, $message, $headers);
?>
mysql_connect("db97.xxxxx","xxxx","xxxx");
mysql_select_db("xxxx");
$queryofferte1="SELECT DATE_FORMAT(sluitingsdatum, '%d-%m-%Y')
AS datumNL, datum, vertrek, aankomst, type, status, offerteid, personen from offerte WHERE sluitingsdatum = CURDATE() AND status ='open'";
$resultofferte1=mysql_db_query("xxx",$queryofferte1);
$message = '<html>
<head>
<title>xxxx</title>
</head>
<body>
<p><img src="http://xxx.jpg" width="800" height="85" /></p>
<p> </p>
<table width="776" border="1">';
while($objectofferte1=mysql_fetch_object($resultofferte1))
{
$message .= '
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>'.$objectofferte1->vertrek.'</td>
<td>'.$objectofferte1->aankomst.'</td>
<td>'.$objectofferte1->type.'</td>
<td>'.$objectofferte1->personen.'</td>
<td>'.$objectofferte1->datum.'</td>
<td>'.$objectofferte1->datumNL.'</td>
</tr>';
}
$message .=' <tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>';
$to = 'xxx';
$onderwerp = "Proef mailing";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "xxx";
$subject = 'proef mailing';
mail($to, $subject, $message, $headers);
?>
Gr. Marco