时间:2021-07-01 10:21:17 帮助过:27人阅读
$from = 'jarray@foxmail.com'; $subject = $_POST['subject']; $text = $_POST['elvismail']; $dbc = mysqli_connect('localhost', 'root', '', 'elvis_store') or die('Error connecting to MySQL server.'); $query = "SELECT * FROM email_list"; $result = mysqli_query($dbc, $query) // 执行SQL语句 or die('Error querying database.'); while ($row = mysqli_fetch_array($result)){ // while循环条件是mysqli_fetch_array()函数的返回值 $to = $row['email']; $first_name = $row['first_name']; $last_name = $row['last_name']; $msg = "Dear $first_name $last_name,\n$text"; mail($to, $subject, $msg, 'From:' . $from); echo 'Email sent to: ' . $to . '
'; } mysqli_close($dbc); ?>
以上就介绍了Head First PHP&MySQL学习笔记(二),包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。