php – 来自mysqli_Query的回声结果

前端之家收集整理的这篇文章主要介绍了php – 来自mysqli_Query的回声结果前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在制作一个供我自己使用的个人脚本,我需要知道如何回应mysqli_query的结果.我的代码如下:

$conn = MysqLi_connect($servername,$username,$password,$dbname);

if(isset($_POST['commercial'])){
if (isset($_POST['0'])){
    $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 1 AND sent='a'";
    $resultsd1 = MysqLi_query($conn,$sql);
    echo $resultsd1;
}   
if (isset ($_POST['1'])){
    $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 2 AND sent='a'";
    $resultsd2 = MysqLi_query($conn,$sql);
    echo $resultsd2;
}   
if (isset($_POST['2'])){
    $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 3 AND sent='a'";
    $resultsd3 = MysqLi_query($conn,$sql);
    echo $resultsd3;
}
if (isset ($_POST['3'])){
    $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 4 AND sent='a'";
    $resultsd4 = MysqLi_query($conn,$sql);
    echo $resultsd4;
}
if (isset ($_POST['4'])){
    $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 5 AND sent='a'";
    $resultsd5 = MysqLi_query($conn,$sql);
    echo $resultsd5;
}

}
?>
最佳答案
如果你想要返回多行

if (isset($_POST['0'])) {
 $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 1 AND sent='a'";
 $resultsd1 = MysqLi_query($conn,$sql);

 while ($row = MysqLi_fetch_assoc($resultsd1))
 {
    echo $row['email'];
 }
}   

如果只有1排

if (isset($_POST['0'])){
 $sql = "SELECT email FROM CommercialEmails WHERE articleid = '$_POST[article]' AND dripid = 1 AND sent='a' LIMIT 1";
 $resultsd1 = MysqLi_query($conn,$sql);

 $row = MysqLi_fetch_assoc($resultsd1);

 echo $row['email'];
}   
@H_403_29@ 原文链接:https://www.f2er.com/mysql/433501.html

猜你在找的MySQL相关文章