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

      <legend id='cI11f'><style id='cI11f'><dir id='cI11f'><q id='cI11f'></q></dir></style></legend>
      1. <tfoot id='cI11f'></tfoot>

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

        单击按钮时更新信息表

        时间:2023-07-29
        <i id='w18YR'><tr id='w18YR'><dt id='w18YR'><q id='w18YR'><span id='w18YR'><b id='w18YR'><form id='w18YR'><ins id='w18YR'></ins><ul id='w18YR'></ul><sub id='w18YR'></sub></form><legend id='w18YR'></legend><bdo id='w18YR'><pre id='w18YR'><center id='w18YR'></center></pre></bdo></b><th id='w18YR'></th></span></q></dt></tr></i><div id='w18YR'><tfoot id='w18YR'></tfoot><dl id='w18YR'><fieldset id='w18YR'></fieldset></dl></div>
          <tbody id='w18YR'></tbody>

          <legend id='w18YR'><style id='w18YR'><dir id='w18YR'><q id='w18YR'></q></dir></style></legend>
        1. <small id='w18YR'></small><noframes id='w18YR'>

              <bdo id='w18YR'></bdo><ul id='w18YR'></ul>
              <tfoot id='w18YR'></tfoot>

                1. 本文介绍了单击按钮时更新信息表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个表格,可以从数据库中选择信息并显示它,我想知道是否有人可以提供代码让我通过单击按钮来更新列?

                  I have a table which will select information from a database and display it, I'm wondering if anyone can provide a code for me to update a column on the click of a button?

                  示例表:(Access=Boolean)

                  Example Table: (Access=Boolean)

                  ID   -   Name   -   Access
                  ---------------------------
                  1   -   John    -    1
                  ---------------------------
                  2   -   Ben     -    1
                  ---------------------------
                  3   -   Terry   -    0
                  ---------------------------
                  

                  我现有的按钮基于引导程序,

                  My exisiting button is based on bootstrap,

                      <button type="button" id="passed" class="btn btn-success btn-flat"><i class="fa fa-check"></i></button>
                      <button type="button" id="insufficient" class="btn btn-danger btn-flat"><i class="fa fa-times"></i></button>
                  

                  我希望有这样的事情,ONCLICK button1 Run $Allowed SQLONCLICK button2 运行 $NotAllowed SQL

                  I was hoping for something like this, ONCLICK button1 Run $Allowed SQL ONCLICK button2 Run $NotAllowed SQL

                  $allowed = mysqli_query($conn," UPDATE users SET Access = "1" WHERE id = '27' ");     
                  $notallowed = mysqli_query($conn," UPDATE users SET Access = "0" WHERE id = '453' ");
                  

                  推荐答案

                  您可以使用带有 post 方法的表单和带有命名属性的提交类型的按钮,并在条件语句中使用这些按钮.

                  You can use a form with a post method and a submit type of buttons with named attributes and use those in a conditional statement.

                  即:

                  旁注:我删除了转义引号,因为我不确定这些引号是否已经设置在 echo 中.

                  Sidenote: I removed the escaped quotes, as I was not sure if those were already set inside an echo.

                  HTML 表单:

                  <form method="post" action="handler.php">
                  
                      <button type="submit" name="passed" id="passed" class="btn btn-success btn-flat"><i class="fa fa-check"></i></button>
                      <button type="submit" name="insufficient" id="insufficient" class="btn btn-danger btn-flat"><i class="fa fa-times"></i></button>
                  
                  </form>
                  

                  PHP:

                  <?php 
                  
                  // db connection
                  
                  if(isset($_POST['passed'])){
                  
                      $allowed = mysqli_query($conn," UPDATE users SET Access = "1" WHERE id = '27' ");
                  
                  }
                  
                  if(isset($_POST['insufficient'])){
                  
                      $notallowed = mysqli_query($conn," UPDATE users SET Access = "0" WHERE id = '453' ");
                  
                  }
                  

                  • 如果这在任何给定点有任何用户交互,请务必小心.

                    • Be careful if this has any user interaction at any given point.

                      使用准备好的语句,或 带有准备好的语句的 PDO它们更安全.

                      脚注:

                      运行 UPDATE 查询时,最好使用 mysqli_affected_rows() 以获得绝对真实性.

                      When running an UPDATE query, it's best to use mysqli_affected_rows() for absolute truthness.

                      • http://php.net/manual/en/mysqli.affected-行.php

                      否则,您可能会得到误报.

                      Otherwise, you may get a false positive.

                      这篇关于单击按钮时更新信息表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么当我将多个查询发送到 mysqli_query 时会发生 下一篇:MYSQLI - 数组中的位置

                  相关文章

                  最新文章

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

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

                  1. <tfoot id='uVo4l'></tfoot>