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

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

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

      1. mysqli_fetch_array while 循环列

        时间:2023-07-31
      2. <tfoot id='FseXs'></tfoot>

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

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

            <legend id='FseXs'><style id='FseXs'><dir id='FseXs'><q id='FseXs'></q></dir></style></legend>
              <tbody id='FseXs'></tbody>
                <bdo id='FseXs'></bdo><ul id='FseXs'></ul>
                  本文介绍了mysqli_fetch_array while 循环列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  应该是非常基本的,但我无法让它工作.我有这个代码来迭代一个 mysqli 查询:

                  Should be pretty basic, but I can't get it to work. I have this code to iterate over a mysqli query:

                  while($row = mysqli_fetch_array($result)) {
                      $posts[] = $row['post_id'].$row['post_title'].$row['content'];
                  }
                  

                  它有效并返回:

                  变量#1:(数组,3 个元素)↵0(字符串):4testtest"(9 个字符)1(字符串):1Hello world!欢迎来到 WordPress.这是您的第一篇文章.编辑或删除它,然后开始写博客!"(99 个字符)2(字符串):2Sample PageThis is an example page.它与博客文章不同,因为它会留在一个地方,并会出现在您的网站导航(在大多数主题中)."(161 个字符)

                  Variable #1: (Array, 3 elements) ↵ 0 (String): "4testtest" (9 characters) 1 (String): "1Hello world!Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!" (99 characters) 2 (String): "2Sample PageThis is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes)." (161 characters)

                  问题是它将所有三个列放在一列中,所以我无法单独访问它们.

                  The problem is that it puts all three colums into one column, so I can't access them seperatly.

                  例如:

                  0(字符串):4testtest"(9 个字符)

                  0 (String): "4testtest" (9 characters)

                  应该分为4个,测试,测试

                  Should be seperated into 4, test, test

                  当我这样做时:

                  while($row = mysqli_fetch_array($result)) {             
                      $posts['post_id'] = $row['post_id'];
                      $posts['post_title'] = $row['post_title'];
                      $posts['type'] = $row['type'];
                      $posts['author'] = $row['author'];  
                  }   
                  

                  它只输出 1 行而不是所有三行......

                  It only outputs 1 row instead of all three …

                  非常感谢任何帮助!

                  推荐答案

                  从 MySQL 获取所有值:

                  Get all the values from MySQL:

                      $post = array();
                      while($row = mysql_fetch_assoc($result))
                      {
                          $posts[] = $row;
                      }
                  

                  然后,获取每个值:

                  <?php 
                       foreach ($posts as $row) 
                          { 
                              foreach ($row as $element)
                              {
                                  echo $element."<br>";
                              }
                          }
                  ?>
                  

                  回显值.或者从 $post 变量中获取每个元素

                  To echo the values. Or get each element from the $post variable

                  这篇关于mysqli_fetch_array while 循环列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:mysqli fetch_all() 不是一个有效的函数? 下一篇:MySQLi 中的参数

                  相关文章

                  最新文章

                1. <tfoot id='6OMsI'></tfoot>

                  <small id='6OMsI'></small><noframes id='6OMsI'>

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