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

    <bdo id='U4Rrq'></bdo><ul id='U4Rrq'></ul>
  • <tfoot id='U4Rrq'></tfoot>
    <legend id='U4Rrq'><style id='U4Rrq'><dir id='U4Rrq'><q id='U4Rrq'></q></dir></style></legend>

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

      1. MySQLi 查询只返回一行

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

      3. <legend id='ozBFp'><style id='ozBFp'><dir id='ozBFp'><q id='ozBFp'></q></dir></style></legend>
          <tbody id='ozBFp'></tbody>
      4. <tfoot id='ozBFp'></tfoot>

              • <bdo id='ozBFp'></bdo><ul id='ozBFp'></ul>

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

                  本文介绍了MySQLi 查询只返回一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这段代码只返回一行,但应该返回两行.我在 phpMyAdmin 中尝试了 SQL,它完美地返回了 2 行.我在这里做错了什么?

                  This code only returns one row, but it should return 2 rows. I have tried the SQL in phpMyAdmin and it perfectly returned 2 rows. What am I doing wrong here?

                  $request_list_result = $mysqli->query("
                  SELECT buddy_requester_id, buddy_reciepient_id, user_id, user_fullname FROM sb_buddies
                  JOIN sb_users ON buddy_requester_id=user_id
                  WHERE buddy_status='0' AND buddy_reciepient_id='". get_uid() ."'");
                  
                  $request_list_row = $request_list_result->fetch_array();
                  
                  echo $request_list['user_fullname'];
                  

                  顺便说一下,上面的代码是通过以下脚本获取到 profile.php 的过程:

                  By the way, the code above is getting process to profile.php via following script:

                  $index = new Template('views/template/one.php', array(
                  'subtitle' => 'Dashboard',
                  'stylesheets' => array('/assets/css/profile.css'),
                  'scripts' => array('/assets/js/dashboard.js'),
                  'sidebar' => 'sidebar.php',
                  'content' => 'views/profile.php',
                  'errors' => $errors,
                  'successes' => $successes,
                  'request_list' => $request_list_row //right here
                  ), true);
                  

                  推荐答案

                  你需要遍历结果(正如 TheSmose 提到的)

                  You need to loop through the results (as TheSmose mentioned)

                  while ($request_list_row = $request_list_result->fetch_array()) {
                      echo $request_list['user_fullname'];
                  }
                  

                  AND 您需要将结果数组 $request_list 发送到模板而不是 $request_list_row.

                  AND you need to send the resulting array $request_list to the template rather than $request_list_row.

                  改变这个

                  'request_list' => $request_list_row //right here
                  

                  至此

                  'request_list' => $request_list //right here
                  

                  如果您想要的不仅仅是模板中的 user_fullname(并且您没有 mysqli_result::fetch_all 所需的 PHP >= 5.3),那么您将需要在循环内建立你自己的数组.

                  If you want more than just user_fullname in your template (and you don't have PHP >= 5.3 required for mysqli_result::fetch_all), then you will need to build up your own array inside the loop.

                  我不知道您的模板代码期望什么,但您可以尝试

                  I don't know what your template code expects, but you could try

                  while ($request_list_row = $request_list_result->fetch_array()) {
                      echo $request_list[] = $request_list_row;
                  }
                  

                  这篇关于MySQLi 查询只返回一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:获取带有 mysqli 结果的行数组 下一篇:如何将 mysqli 结果转换为 JSON?

                  相关文章

                  最新文章

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

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