PHP批量查詢WordPress留言者E-mail地址實現(xiàn)方法

字號:


    這篇文章主要介紹了PHP批量查詢WordPress留言者E-mail地址實現(xiàn)方法,本文直接給出實現(xiàn)代碼,需要的朋友可以參考下
    今天收到了很多Bloger朋友的E-mail拜年短信,嘿嘿,感覺很好玩,可是他們是如何實現(xiàn)的這個呢,很簡單的,可是簡單的分為兩步:
    1)通過SQL查詢獲取E-mail地址
    2)通過某種方法群發(fā)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 郵件群發(fā)工具 Designed By Kaisir</title>
    </head>
    <body>
    <?php
    //要連接的數(shù)據(jù)庫地址
    $db_server="localhost";
    //數(shù)據(jù)庫用戶名
    $db_user_name="這里改成你的數(shù)據(jù)庫用戶名";
    //數(shù)據(jù)庫密碼
    $db_user_password="這里改成你的數(shù)據(jù)庫的密碼";
    //數(shù)據(jù)庫名
    $db_name="這里改成你的數(shù)據(jù)庫名";
    //以下代碼請不要修改
    $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>數(shù)據(jù)庫連接失敗!請檢查用戶名密碼!</p>";
    exit(0);
    }
    $flag=mysql_select_db($db_name,$conn);
    if(!$flag)
    {
    echo"<p>數(shù)據(jù)庫連接正常,但無法打開指定的數(shù)據(jù)庫!</p>";
    exit(0);
    }
    //執(zhí)行查詢
    $result=mysql_query($sql,$conn);
    while($row=mysql_fetch_array($result))
    {
    ?>
    <?echo $row["comment_author_email"]?>,
    <?php
    }
    mysql_close($conn);//關(guān)閉數(shù)據(jù)庫連接
    ?>
    </body>
    </html>