如何使用php从mysql数据库中获取数据 [英] how to fetch data from mysql database using php

查看:55
本文介绍了如何使用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

这篇关于如何使用php从mysql数据库中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆