如何使用php从mysql数据库中获取数据
问题描述:
我如何使用 php 从 mysql 数据库中获取数据并触发一封邮件到我从 mysql 数据库中获取的那些电子邮件 ID,并且还想在邮件主题中包含另外两个数据.无法添加代码.任何人都可以帮我如何添加代码??
How can i fetch data from mysql database using php and trigger a mail to those email ids which i have taken from mysql database and also want to include two more data in the mail subject.NOt able to add code.can any one help me how to add the code??
答
这里是示例代码:
$headers = 'From: youremailgoes@here.com' . "\r\n";
$mysqli = new mysqli("localhost", "user", "password", "database");
$output = $mysqli->prepare("SELECT id FROM table WHERE x=?");
$output->bind_param("s", $parameter);
$output->execute();
$output->store_result();
$output->bind_result($id);
while ($output->fetch())
{
mail($to, $subject, $emailcontent, $additionalheader);
}
$output->close();
看看这些链接:
1. http://php.net/manual/de/mysqli.quickstart.prepared-statements.php
2. http://us3.php.net/manual/de/book.mail.php