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

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

        • <bdo id='QtcyE'></bdo><ul id='QtcyE'></ul>
        <tfoot id='QtcyE'></tfoot>

      2. 准备好的语句 - 行数

        时间:2023-07-30
          <tbody id='fCWgJ'></tbody>

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

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

                • <legend id='fCWgJ'><style id='fCWgJ'><dir id='fCWgJ'><q id='fCWgJ'></q></dir></style></legend>
                  本文介绍了准备好的语句 - 行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我只是想弄清楚如何确定行数,然后在 HTML 中显示该数字.

                  I'm just trying to figure out how to determine the number of rows and then make that number display in the HTML.

                  我准备好的语句如下所示:

                  My prepared statement looks like this:

                  if($stmt = $mysqli -> prepare("SELECT field1, field2, field3 FROM table WHERE id= ?ORDER BY id ASC")) 
                      {
                      /* Bind parameters, s - string, b - blob, i - int, etc */
                      $stmt -> bind_param("i", $id);
                      $stmt -> execute();
                      
                      /* Bind results */
                      $stmt -> bind_result($testfield1, $testfield2, $testfield3);
                      
                      /* Fetch the value */
                      $stmt -> fetch();
                  
                      /* Close statement */
                      $stmt -> close();
                     }
                  

                  我知道我应该先保存结果,然后使用 num_rows,就像这样:

                  I understand that I'm supposed to first save the results, then use num_rows, like this:

                  $stmt->store_result();
                  $stmt->num_rows;
                  

                  但是,我正在运行,当我将代码放入其中时,页面会出现问题.我什至无法进入如何显示行数的下一步

                  However, I'm running, and issue with the page bugging out when I put that code in there. I haven't even been able to get to the next step of how to display the number of rows

                  在计算准备好的语句中的行数方面我缺少什么,那么我将如何使用 <?php echo '# rows: '.$WHATGOESHERE;?>

                  What am I missing in terms of calculating the number of rows inside the prepared statement, then how would I display it with a <?php echo '# rows: '.$WHATGOESHERE;?>

                  推荐答案

                  num_rows 返回数字,您必须将其存储在变量中.

                  num_rows returns the number, you have to store it in a variable.

                  /*.....other code...*/
                  $numberofrows = $stmt->num_rows;
                  /*.....other code...*/
                      
                  echo '# rows: '.$numberofrows;
                  

                  所以完整的代码应该是这样的:

                  So full code should be something like this:

                  $stmt = $mysqli -> prepare("SELECT field1, field2, field3 FROM table WHERE id= ? ORDER BY id ASC");
                  /* Bind parameters, s - string, b - blob, i - int, etc */
                  $stmt -> bind_param("i", $id);
                  $stmt -> execute();
                  $stmt -> store_result();
                  
                  /* Bind results */
                  $stmt -> bind_result($testfield1, $testfield2, $testfield3);
                  
                  /* Fetch the value */
                  $stmt -> fetch();
                  $numberofrows = $stmt->num_rows;
                  
                  /* Close statement */
                  $stmt -> close();
                  
                  echo '# rows: '.$numberofrows;
                  

                  这篇关于准备好的语句 - 行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                    <legend id='HqgKE'><style id='HqgKE'><dir id='HqgKE'><q id='HqgKE'></q></dir></style></legend>

                      <tbody id='HqgKE'></tbody>

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

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