• <tfoot id='t673C'></tfoot>
  • <legend id='t673C'><style id='t673C'><dir id='t673C'><q id='t673C'></q></dir></style></legend>

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

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

      1. 如何在单击按钮时执行mysql

        How to execute mysql on button click(如何在单击按钮时执行mysql)
        <tfoot id='bwvLY'></tfoot>
          <i id='bwvLY'><tr id='bwvLY'><dt id='bwvLY'><q id='bwvLY'><span id='bwvLY'><b id='bwvLY'><form id='bwvLY'><ins id='bwvLY'></ins><ul id='bwvLY'></ul><sub id='bwvLY'></sub></form><legend id='bwvLY'></legend><bdo id='bwvLY'><pre id='bwvLY'><center id='bwvLY'></center></pre></bdo></b><th id='bwvLY'></th></span></q></dt></tr></i><div id='bwvLY'><tfoot id='bwvLY'></tfoot><dl id='bwvLY'><fieldset id='bwvLY'></fieldset></dl></div>
            1. <small id='bwvLY'></small><noframes id='bwvLY'>

              <legend id='bwvLY'><style id='bwvLY'><dir id='bwvLY'><q id='bwvLY'></q></dir></style></legend>
                <tbody id='bwvLY'></tbody>
                <bdo id='bwvLY'></bdo><ul id='bwvLY'></ul>
                  本文介绍了如何在单击按钮时执行mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  PHP:
                  单击按钮时如何执行 SQL?我会使用 JavaScript onClick() 函数还是其他方式?我正在尝试在循环中执行此操作,并且仅在单击按钮的行上执行 sql ...谢谢!

                  PHP:
                  How would I execute SQL when a button is clicked? Would I do it with the JavaScript onClick() function, or some other way? I am trying to do this inside of a loop, and only execute the sql on the row that the button is clicked on... Thanks!

                  @PHPnoOb 的代码可提供帮助:好的,所以现在我已经整理好了所有这些,但是当单击按钮时,它会为每一行执行一次……而不仅仅是单击按钮的那一行!我只想查询单击按钮的行...我的代码:

                  Code for @PHPnoOb to help: Okay, so now I have all of that sorted out, but when the button is clicked it executes once for each row... not just once for the row the button was clicked on! I only want the row that the button was clicked on to be queried... my code:

                  while($row = mysqli_fetch_array($result)) {
                  
                  //FAULTY CODE!!! EXECUTES ONCE FOR EACH ROW!
                  //I WANT IT TO ONLY EXECUTE FOR THE ROW THE
                  //BUTTON WAS CLICKED ON
                  
                  if(isset($_POST['delete'])){
                  echo "You clicked on: ".$row['subject'];
                  //eventually i will have sql query up here
                  }
                  //echo all the results into a table... messy
                  echo"
                  
                  <tr><td><div align='center'><font color='grey'>".$row['date']."</font></div></td><td><div align='center'> ".$row['sender']."</div></td><td><div align='center'> ".$row['subject']."</div></td><td><div align='center'><input type='button' value='open' onClick='window.alert("On ".$row['date']." ".$row['sender']." wrote:\n".$row['message']."")'/></div></td><td><div align='center'><form  method='post'><input type='submit' value='delete' name='delete'/></form></div></td></tr>
                  
                  ";
                  
                  }
                  
                  echo '</table>'; //ends the table.
                  

                  推荐答案

                  您可以执行类似的操作来保存输入/提交 btn 中的值.

                  You can do something like this to save a value from an input/submit btn.

                  <!-- your html form -->
                  <form action="POST">
                      <input type='text' name='username' />
                      <input type='text' value='submit' />
                  </form>
                  
                  
                  
                  <?php 
                  
                  // your php code
                  
                  if($_POST && isset($_POST['username'])){
                  
                      $db = new PDO('......'); // enter your db details
                  
                      $stmt = $db->prepare("INSERT INTO table (username) VALUES (?)");
                      $result = $stmt->execute(array($_POST['username']);
                  
                      echo $result->rowCount() ? 'Username saved in db' : 'Unknown error occured'; 
                  
                  }
                  

                  这篇关于如何在单击按钮时执行mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <bdo id='vFa0U'></bdo><ul id='vFa0U'></ul>
                      <tbody id='vFa0U'></tbody>
                    <legend id='vFa0U'><style id='vFa0U'><dir id='vFa0U'><q id='vFa0U'></q></dir></style></legend>

                  • <small id='vFa0U'></small><noframes id='vFa0U'>

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