【发布时间】:2015-07-08 12:48:40
【问题描述】:
代码:
<?php
$servername = "localhost";
$username = "username";
$password = "****";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT email, name FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$conn->close();
?>
<table width="348" border="0">
<tr>
<td width="88">Name</td>
<td width="98">Email</td>
<td width="148">Select All
<label>
<input type="checkbox" name="checkbox" id="checkbox">
</label> </td>
</tr>
<tr>
<?php {?><td><?php echo $row["name"];?>
}
</td>
<td><?php echo $row["email"];?></td>
<td><label>
<input type="checkbox" name="checkbox" id="checkbox">
</label></td><?php } else {
echo "0 results";
}?>
</tr>
<tr>
<td> </td>
<td> </td>
<td><label>
<input type="submit" name="button" id="button" value="Send">
</label></td>
</tr>
</table>
我想向表格中列出的电子邮件用户发送附有 pdf 文件的电子邮件。我在一个名为“slips”的文件夹中有一个生成的 pdf 文件,其中包含电子邮件作为文件名,例如每个文件名都带有数据库中电子邮件的名称,例如。 smith@test.com 在电子邮件栏中和一个名为 smith@test.com.pdf 的 pdf 文件
解决此类问题的最佳 php 代码是什么。
【问题讨论】:
标签: php mysql pdf-generation email-attachments