内容 |
这篇文章主要介绍了PHP批量查询WordPress留言者E-mail地址实现方法,本文直接给出实现代码,需要的朋友可以参考下 今天收到了很多Bloger朋友的E-mail拜年短信,嘿嘿,感觉很好玩,可是他们是如何实现的这个呢,很简单的,可是简单的分为两步: 1)通过SQL查询获取E-mail地址 2)通过某种方法群发E-mail 对于1,几行PHP代码可以解决: 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " xmlns=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>WordPress 邮件群发工具 Designed By Kaisir</title> </head> <body> <?php //要连接的数据库地址 $db_server="localhost"; //数据库用户名 $db_user_name="这里改成你的数据库用户名"; //数据库密码 $db_user_password="这里改成你的数据库的密码"; //数据库名 $db_name="这里改成你的数据库名"; //以下代码请不要修改 $sql="SELECT DISTINCT comment_author_email FROM `blog_comments` WHERE 1"; $conn=mysql_connect($db_server,$db_user_name,$db_user_password); if(!$conn) { echo"<p>数据库连接失败!请检查用户名密码!</p>"; exit(0); } $flag=mysql_select_db($db_name,$conn); if(!$flag) { echo"<p>数据库连接正常,但无法打开指定的数据库!</p>"; exit(0); } //执行查询 $result=mysql_query($sql,$conn); while($row=mysql_fetch_array($result)) { ?> <?echo $row["comment_author_email"]?>, <?php } mysql_close($conn);//关闭数据库连接 ?> </body> </html> |