我正在制作一个供我自己使用的个人脚本,我需要知道如何回应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'];}
总结 以上是内存溢出为你收集整理的php – 来自mysqli_Query的回声结果全部内容,希望文章能够帮你解决php – 来自mysqli_Query的回声结果所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)