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

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

      <legend id='80flS'><style id='80flS'><dir id='80flS'><q id='80flS'></q></dir></style></legend>
      • <bdo id='80flS'></bdo><ul id='80flS'></ul>

      <small id='80flS'></small><noframes id='80flS'>

    1. 將數組轉換為單獨的字符串

      convert an array into individual strings(將數組轉換為單獨的字符串)
    2. <i id='v6usa'><tr id='v6usa'><dt id='v6usa'><q id='v6usa'><span id='v6usa'><b id='v6usa'><form id='v6usa'><ins id='v6usa'></ins><ul id='v6usa'></ul><sub id='v6usa'></sub></form><legend id='v6usa'></legend><bdo id='v6usa'><pre id='v6usa'><center id='v6usa'></center></pre></bdo></b><th id='v6usa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='v6usa'><tfoot id='v6usa'></tfoot><dl id='v6usa'><fieldset id='v6usa'></fieldset></dl></div>
        <tbody id='v6usa'></tbody>

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

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

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

                本文介紹了將數組轉換為單獨的字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有以下數組,我想將它們中的每一個都轉換為單獨的字符串.換句話說,將數組分解為單獨的部分.

                I have the following arrays and I would like to convert each one of them into individual strings. In other words, break the array into individual pieces.

                  $formatsArray = $_POST['formats'];
                      $topicsArray = $_POST['topics'];
                

                這是因為我想在以下查詢中包含單個字符串

                This is because I would like to include the individual strings in the following query "

                  $resources = "select * from resources where
                                    stage LIKE '%".$stage."%'
                                    AND format LIKE '%".$formats."%'";
                
                
                      $run_query = mysqli_query($con, $resources);
                

                這是因為 format 需要一個單獨的字符串進行比較,例如假設數組是 ["video", "blogs", "articles"],如果 format 是與 video,blogs,articles 相比,而不是視頻,博客或文章.

                This is because format expect an individual string for comparison, such as lets assume the array is ["video", "blogs", "articles"], it wouldn't work if format was to be compared with video,blogs,articles but rather video, blogs or articles.

                我希望這很清楚,如有任何澄清,請提供建議.

                I hope this is clear, and for any clarification, please advise.

                一切順利,

                更新:

                $formats = explode(',', $formatsArray);
                      $topics = explode(',', $topicsArray);
                
                
                      $resources = "select * from resources where
                                    stage LIKE '%".$stage."%'
                                    AND format LIKE '%".$formats."%' AND topic LIKE '%".$topics."%' ";
                

                更新:

                $run_query = mysqli_query($con, $resources);
                
                
                  while($row = mysqli_fetch_array($run_query)) {
                
                    $data[] = array(
                      'format' => $row['format'],
                      'title' => $row['title'],
                      'costs' => $row['cost'],
                      'stage' => $row['stage'],
                      'topic' => $row['topic'],
                      'link' => $row['link']
                    );
                  }
                

                更新

                  include('db.php');
                
                
                  $query = 'select * from resources where ';
                  $query .= 'stage LIKE :stage and';
                  $execute[':stage'] = '%' . $stage . '%';
                  if(!empty($_POST['formats'])){
                  foreach($_POST['formats'] as $key => $format) {
                      $query .= 'format LIKE :format' . $key . ' and ';
                      $execute[':format' . $key] = '%' . trim($format) . '%';
                  }
                  }
                  if(!empty($_POST['topics'])){
                  foreach($_POST['topics'] as $key => $topic) {
                      $query .= 'topic LIKE :topic' . $key . ' and ';
                      $execute[':topic' . $key] = '%' . trim($topic)  . '%';
                  }
                  }
                  $query = rtrim($query, ' and ');
                  if(!empty($execute)) {
                      $stmt = $con->prepare($query);
                      $stmt->execute($execute);
                  } else {
                      echo 'You must search for something';
                  }
                
                
                      while($row = mysqli_fetch_array($query)) {
                
                        $data[] = array(
                          'format' => $row['format'],
                          'title' => $row['title'],
                          'costs' => $row['cost'],
                          'stage' => $row['stage'],
                          'topic' => $row['topic'],
                          'link' => $row['link']
                        );
                      }
                

                推薦答案

                我認為這樣做可以.這也將通過使用準備好的語句來解決注入漏洞.

                I think this would do it. This also will resolve the injection hole by using prepared statements.

                $query = 'select * from resources where ';
                if(!empty($_POST['formats'])){ 
                foreach($_POST['formats'] as $key => $format) {
                    $query .= 'stage LIKE :stage' . $key . ' or ';
                    $execute[':stage' . $key] = '%' . trim($format) . '%';
                }
                }
                if(!empty($_POST['topics'])){
                foreach($_POST['topics'] as $key => $topic) {
                    $query .= 'topic LIKE :topic' . $key . ' or ';
                    $execute[':topic' . $key] = '%' . trim($topic)  . '%';
                }
                }
                $query = rtrim($query, ' or ');
                if(!empty($execute)) {
                    echo $query;
                    print_r($execute);
                    //$stmt = $mysqli->prepare($query);
                    //$stmt->execute($execute);
                } else {
                    echo 'You must search for something';
                }
                

                給你一個查詢

                select * from resources where stage LIKE :stage0 or stage LIKE :stage1 or topic LIKE :topic0 or topic LIKE :topic1 or topic LIKE :topic2 or topic LIKE :topic3

                select * from resources where stage LIKE :stage0 or stage LIKE :stage1 or topic LIKE :topic0 or topic LIKE :topic1 or topic LIKE :topic2 or topic LIKE :topic3

                和綁定值:

                Array
                (
                    [:stage0] => %test%
                    [:stage1] => %test1%
                    [:topic0] => %value1%
                    [:topic1] => %value2%
                    [:topic2] => %value3%
                    [:topic3] => %value4%
                )
                

                這是我認為數據已配對時的初始代碼..

                Here's the initial code I had for when I thought the data was paired..

                foreach($formats as $key => $format) {
                    $topic = $topics[$key];
                    $query .= '(stage LIKE :stage' . $key . ' and topic LIKE :topic' . $key . ') or ';
                    $execute[':stage' . $key] = '%' . trim($format) . '%';
                    $execute[':topic' . $key] = '%' . trim($topic)  . '%';
                }
                

                關于準備好的語句的一些鏈接:
                http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
                http://php.net/manual/en/mysqli.prepare.php
                http://php.net/manual/en/mysqli-stmt.execute.php

                A few links on prepared statements:
                http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
                http://php.net/manual/en/mysqli.prepare.php
                http://php.net/manual/en/mysqli-stmt.execute.php

                這篇關于將數組轉換為單獨的字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

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

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

                1. <tfoot id='BoI1C'></tfoot>
                          <tbody id='BoI1C'></tbody>
                        <legend id='BoI1C'><style id='BoI1C'><dir id='BoI1C'><q id='BoI1C'></q></dir></style></legend>

                          <bdo id='BoI1C'></bdo><ul id='BoI1C'></ul>
                          主站蜘蛛池模板: 操到爽 | 欧美一级毛片免费观看 | 日韩欧美不卡 | 本道综合精品 | 九九伦理片 | 亚洲精品一区在线 | 欧美久久综合 | 日韩午夜电影在线观看 | 成人免费观看网站 | 九色 在线 | 久草新在线 | 精品综合久久久 | 日本久久久影视 | 久久久噜噜噜www成人网 | 久久国产精品-国产精品 | 日本特黄特色aaa大片免费 | 成人免费视频网站在线看 | 国产乱一区二区三区视频 | 欧美激情视频一区二区三区在线播放 | 在线国产一区 | 国产在线精品一区二区三区 | 成人久久网 | 二区高清| 久久中文一区二区 | 福利视频一区二区 | 欧美9999 | 免费能直接在线观看黄的视频 | 国产精品视频不卡 | 人人天天操 | 国产一区二区在线播放视频 | www.亚洲国产精品 | 黄色三级毛片 | 成人在线视频免费播放 | 国产精品美女久久久久aⅴ国产馆 | 99国内精品久久久久久久 | 成人高清网站 | 国产乱码精品一区二区三区五月婷 | 91在线第一页 | 久久午夜剧场 | 日韩国产一区二区三区 | 日本精品视频一区二区 |