<legend id='Zl5lf'><style id='Zl5lf'><dir id='Zl5lf'><q id='Zl5lf'></q></dir></style></legend>
      <bdo id='Zl5lf'></bdo><ul id='Zl5lf'></ul>
  • <tfoot id='Zl5lf'></tfoot>
  • <i id='Zl5lf'><tr id='Zl5lf'><dt id='Zl5lf'><q id='Zl5lf'><span id='Zl5lf'><b id='Zl5lf'><form id='Zl5lf'><ins id='Zl5lf'></ins><ul id='Zl5lf'></ul><sub id='Zl5lf'></sub></form><legend id='Zl5lf'></legend><bdo id='Zl5lf'><pre id='Zl5lf'><center id='Zl5lf'></center></pre></bdo></b><th id='Zl5lf'></th></span></q></dt></tr></i><div id='Zl5lf'><tfoot id='Zl5lf'></tfoot><dl id='Zl5lf'><fieldset id='Zl5lf'></fieldset></dl></div>

      <small id='Zl5lf'></small><noframes id='Zl5lf'>

        在另一个while循环内的while循环内执行mysqli准备好

        时间:2023-09-20
      1. <small id='9dPO4'></small><noframes id='9dPO4'>

          <tbody id='9dPO4'></tbody>
        <i id='9dPO4'><tr id='9dPO4'><dt id='9dPO4'><q id='9dPO4'><span id='9dPO4'><b id='9dPO4'><form id='9dPO4'><ins id='9dPO4'></ins><ul id='9dPO4'></ul><sub id='9dPO4'></sub></form><legend id='9dPO4'></legend><bdo id='9dPO4'><pre id='9dPO4'><center id='9dPO4'></center></pre></bdo></b><th id='9dPO4'></th></span></q></dt></tr></i><div id='9dPO4'><tfoot id='9dPO4'></tfoot><dl id='9dPO4'><fieldset id='9dPO4'></fieldset></dl></div>
          <legend id='9dPO4'><style id='9dPO4'><dir id='9dPO4'><q id='9dPO4'></q></dir></style></legend>
          <tfoot id='9dPO4'></tfoot>

            • <bdo id='9dPO4'></bdo><ul id='9dPO4'></ul>

                1. 本文介绍了在另一个while循环内的while循环内执行mysqli准备好的语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在努力实现以下目标:

                  I am trying to achieve the following:

                  User 1:
                       - Alert 1 Email
                       - Alert 2 Email
                  User 2:
                       - Alert 1 Email
                       - Alert 2 Email
                  

                  我试图在另一个运行 mysqli 准备好的语句的 while 循环中使用一个 while 循环来完成此操作,但我无法让它工作.

                  I'm trying to accomplish this with a while loop inside another while loop that is running a mysqli prepared statement, but I cannot get it to work.

                  代码:

                  $stmtAdd = $conn->prepare("INSERT INTO Data (row1, row2, row3, row4) VALUES ('".$row1."', '".$row2."', '".$row3."', '".$row4."')");
                  $stmtAdd->execute();
                  $stmtAdd->close();
                  
                  $stmtUsers = $conn->prepare("SELECT username, setting1 FROM Users");
                  $stmtUsers->store_result();
                  if ($stmtUsers->execute() === FALSE) {
                      die("Could not execute prepared statement");
                  } else {
                      $stmtUsers->bind_result($user, $setting1);
                      while ($stmtUsers->fetch()) {
                          /* Check if each user has setting 1 disabled */
                          if ($setting1 == '0'){
                              /* Check if any alerts exist for each user */
                              $stmtUsersAlerts = $conn->prepare("SELECT name, filter, email FROM Alerts WHERE user='".$user."' AND type='1'");
                              $stmtUsersAlerts->store_result();
                              $stmtUsersAlerts->bind_result($name, $filter, $email);
                              while ($stmtUsersAlerts->fetch()) {
                                  /* Send email */
                              }
                              $stmtUsersAlerts->close();
                          }
                      }
                      $stmtUsers->close();
                  }
                  

                  推荐答案

                  stmt->store_result() 不能在 stmt->execute() 之前运行.

                  stmt->store_result() can not run before stmt->execute().

                  $stmtUsers = $conn->prepare("SELECT username, setting1 FROM Users");
                  if ($stmtUsers->execute() === FALSE) {
                      die("Could not execute prepared statement");
                  } else {
                      $stmtUsers->store_result();                // After execute()
                      $stmtUsers->bind_result($user, $setting1);
                      while ($stmtUsers->fetch()) {
                          /* Check if each user has setting 1 disabled */
                          if ($setting1 == '0'){
                              /* Check if any alerts exist for each user */
                              $stmtUsersAlerts = $conn->prepare("SELECT name, filter, email FROM Alerts WHERE user='".$user."' AND type='1'");
                              $stmtUsersAlerts->execute();        // This line was missing
                              $stmtUsersAlerts->store_result();
                              $stmtUsersAlerts->bind_result($name, $filter, $email);
                              while ($stmtUsersAlerts->fetch()) {
                                  /* Send email */
                              }
                              $stmtUsersAlerts->close();
                          }
                      }
                      $stmtUsers->close();
                  }
                  

                  这篇关于在另一个while循环内的while循环内执行mysqli准备好的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:第二个while循环没有运行.为什么? 下一篇:如何在php pdo中使用where子句多次调用函数?

                  相关文章

                  最新文章

                  <i id='LBuGd'><tr id='LBuGd'><dt id='LBuGd'><q id='LBuGd'><span id='LBuGd'><b id='LBuGd'><form id='LBuGd'><ins id='LBuGd'></ins><ul id='LBuGd'></ul><sub id='LBuGd'></sub></form><legend id='LBuGd'></legend><bdo id='LBuGd'><pre id='LBuGd'><center id='LBuGd'></center></pre></bdo></b><th id='LBuGd'></th></span></q></dt></tr></i><div id='LBuGd'><tfoot id='LBuGd'></tfoot><dl id='LBuGd'><fieldset id='LBuGd'></fieldset></dl></div>

                      <tfoot id='LBuGd'></tfoot>

                      <small id='LBuGd'></small><noframes id='LBuGd'>

                        <bdo id='LBuGd'></bdo><ul id='LBuGd'></ul>
                    1. <legend id='LBuGd'><style id='LBuGd'><dir id='LBuGd'><q id='LBuGd'></q></dir></style></legend>