久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

    2. <legend id='sTHOW'><style id='sTHOW'><dir id='sTHOW'><q id='sTHOW'></q></dir></style></legend>

          <bdo id='sTHOW'></bdo><ul id='sTHOW'></ul>

        Mysqli 查詢不能工作兩次

        Mysqli query doesn#39;t work twice(Mysqli 查詢不能工作兩次)

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

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

                1. 本文介紹了Mysqli 查詢不能工作兩次的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我無法同時使用 Mysqli 查詢.如果我在 html 中注釋掉一個函數,另一個函數就會正確執行,反之亦然.

                  function all_posts() {require_once 'database.inc.php';$mysqli = mysqli_connect($host, $username, $password, $database);$query = mysqli_query($mysqli, "SELECT variable_name, post_name, post_date, post_display FROM blog_posts ORDER BY id DESC LIMIT 5");如果(!$查詢)回聲 mysqli_error();而 ($results = mysqli_fetch_assoc($query)) {$post_name = $results['post_name'];$post_date = $results['post_date'];$post_display = $results['post_display'];$variable_name = $results['variable_name'];echo "";echo "

                  ";echo "

                  ";echo "<h2>{$post_name}</h2>";echo "<h3>{$post_date}</h3>";回聲</div>";echo "<p>{$post_display}</p>";回聲</div>";回聲</a>";}mysqli_free_result();}函數 all_sidebar_posts() {require_once 'database.inc.php';$mysqli = mysqli_connect($host, $username, $password, $database);$query = mysqli_query($mysqli, "SELECT variable_name, post_name FROM blog_posts ORDER BY id DESC LIMIT 5");而 ($results = mysqli_fetch_assoc($query)) {$post_name = $results['post_name'];$variable_name = $results['variable_name'];echo "<li><a href='posts.php?post=$variable_name'>$post_name</a></li>";}mysqli_free_result();}

                  這是我要輸出到的 html.

                    <?php all_sidebar_posts();?>

                  <div class="content_container"><?php all_posts();?>

                  我嘗試過使用 mysqli_data_seek(); 但沒有成功.也許我沒有正確使用它?我瀏覽了許多問題并找到了類似的問題,但我都嘗試過,但都無濟于事.我是編程新手,所以我可能會忽略一些基本的東西.謝謝大家的幫助!

                  解決方案

                  你做錯了.
                  切勿將您的數據操作代碼與演示代碼混合在一起.

                  首先,將帖子放入數組:

                  require_once 'database.inc.php';mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);$mysqli = mysqli_connect($host, $username, $password, $database);$sql = "SELECT variable_name, post_name, post_date, post_displayFROM blog_posts ORDER BY id DESC LIMIT 5"$result = mysqli_query($mysqli, $sql);$data = 數組();而 ($row = mysqli_fetch_assoc($result)) {$data[] = $row;}

                  然后使用這個 $data 數組在您需要的任何時間顯示帖子,只需使用 foreach()

                  I cannot get my Mysqli queries to both work. If I comment out one function in my html, the other function is properly executed and vice versa.

                  function all_posts() {
                      require_once 'database.inc.php';
                      $mysqli = mysqli_connect($host, $username, $password, $database);
                      $query = mysqli_query($mysqli, "SELECT variable_name, post_name, post_date, post_display FROM blog_posts ORDER BY id DESC LIMIT 5");
                  
                      if (!$query)
                          echo mysqli_error();
                  
                      while ($results = mysqli_fetch_assoc($query)) {
                  
                          $post_name = $results['post_name'];
                          $post_date = $results['post_date'];
                          $post_display = $results['post_display'];
                          $variable_name = $results['variable_name'];
                  
                          echo "<a href='posts.php?post={$variable_name}'>";
                          echo "<div class='entry'>";
                          echo "<div class='entry_header'>";
                          echo "<h2>{$post_name}</h2>";
                          echo "<h3>{$post_date}</h3>";
                          echo "</div>";
                          echo "<p>{$post_display}</p>";
                          echo "</div>";
                          echo "</a>";
                      }
                  
                      mysqli_free_result();
                  }
                  
                  function all_sidebar_posts() {
                  
                      require_once 'database.inc.php';
                      $mysqli = mysqli_connect($host, $username, $password, $database);
                      $query = mysqli_query($mysqli, "SELECT variable_name, post_name FROM blog_posts ORDER BY id DESC LIMIT 5");
                  
                      while ($results = mysqli_fetch_assoc($query)) {
                  
                          $post_name = $results['post_name'];
                          $variable_name = $results['variable_name'];
                          echo "<li><a href='posts.php?post=$variable_name'>$post_name</a></li>";
                      }
                  
                      mysqli_free_result();
                  }
                  

                  Here is the html that I am outputting to.

                  <ul>
                      <?php all_sidebar_posts(); ?>
                  </ul>
                  </div>
                  <div class="content_container">
                      <?php all_posts(); ?>
                  </div>
                  

                  I have tried using mysqli_data_seek(); but haven't had luck. Perhaps I am not using it right? I have browsed many questions and found similar ones but I have tried them all to no avail. I am new to programming so I may be overlooking something basic. Thank you all for the help!

                  解決方案

                  You are doing it wrong way.
                  Never mix your data manipulation code with presentation code.

                  First, get the posts into array:

                  require_once 'database.inc.php';
                  mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
                  $mysqli = mysqli_connect($host, $username, $password, $database);
                  
                  $sql = "SELECT variable_name, post_name, post_date, post_display 
                          FROM blog_posts ORDER BY id DESC LIMIT 5"
                  $result = mysqli_query($mysqli, $sql);
                  $data = array();
                  while ($row = mysqli_fetch_assoc($result)) {
                      $data[] = $row;
                  }
                  

                  and then use this $data array to display posts any times you need, simply using foreach()

                  這篇關于Mysqli 查詢不能工作兩次的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)

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

                    <tfoot id='PjXeT'></tfoot>
                      <i id='PjXeT'><tr id='PjXeT'><dt id='PjXeT'><q id='PjXeT'><span id='PjXeT'><b id='PjXeT'><form id='PjXeT'><ins id='PjXeT'></ins><ul id='PjXeT'></ul><sub id='PjXeT'></sub></form><legend id='PjXeT'></legend><bdo id='PjXeT'><pre id='PjXeT'><center id='PjXeT'></center></pre></bdo></b><th id='PjXeT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PjXeT'><tfoot id='PjXeT'></tfoot><dl id='PjXeT'><fieldset id='PjXeT'></fieldset></dl></div>
                      • <bdo id='PjXeT'></bdo><ul id='PjXeT'></ul>
                    1. <small id='PjXeT'></small><noframes id='PjXeT'>

                      主站蜘蛛池模板: 日操操 | 色在线免费视频 | 亚洲一区二区三区久久 | 一区二区三区四区电影视频在线观看 | 99精品一区二区三区 | 一本久久a久久精品亚洲 | 国产午夜精品久久久久 | 日本久久网| 亚洲欧美一区二区三区1000 | 电影91久久久 | 99国产精品99久久久久久 | 另类专区成人 | 天堂va在线 | 国产日韩欧美一区二区 | 国产一区二区不卡 | 夜夜草| 在线观看av不卡 | 99久久精品免费视频 | 超碰在线播 | 日韩精品在线播放 | 国产精品毛片一区二区在线看 | xx性欧美肥妇精品久久久久久 | 中文字幕在线看人 | 欧美日本韩国一区二区 | 久久久久久国产精品久久 | 日韩精品一区二区三区中文在线 | 亚洲成人激情在线观看 | 一区二区三区视频在线观看 | 一区二区三区四区五区在线视频 | 九九热精品视频 | 亚洲欧美一区二区三区在线 | 国产精品久久九九 | 中文字幕91 | 婷婷色在线播放 | 久久久一区二区三区 | 国产在线精品一区二区 | 国产一区二区三区四区 | 中文字幕在线第二页 | 免费成人在线网站 | 不用播放器看的av | 亚洲一级二级三级 |