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

    • <bdo id='1YQrN'></bdo><ul id='1YQrN'></ul>

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

    3. <tfoot id='1YQrN'></tfoot>

      使用 MySQLi 連接到多個數據庫

      Connect to Multiple Databases using MySQLi(使用 MySQLi 連接到多個數據庫)
      <legend id='VitIt'><style id='VitIt'><dir id='VitIt'><q id='VitIt'></q></dir></style></legend>
        <tbody id='VitIt'></tbody>
      <tfoot id='VitIt'></tfoot>

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

          1. <small id='VitIt'></small><noframes id='VitIt'>

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

                本文介紹了使用 MySQLi 連接到多個數據庫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我需要使用 PHP 連接到兩個數據庫,并使用第一個查詢的結果從第二個數據庫中獲取我需要的其余數據.

                I need to connect to two databases using PHP and use the results from the first query to get the rest of the data I need out of a second database.

                因此,對于第二個連接,我需要連接到第二個數據庫并選擇狀態和郵政編碼,其中連接 1(客戶端)的結果等于數據庫 2 中的名字.我該怎么做?

                So for the second connection, I need to connect to the second database and Select state and zipcode where the results from connection 1 (client) is equal to the firstname in database 2. How would I do this?

                <?php
                // check if the 'id' variable is set in URL, and check that it is valid
                if (isset($_GET['cd']) && is_numeric($_GET['cd'])) {
                
                    // get id value
                    $id = intval($_GET['cd']);
                }
                
                $results = $id;
                //Open a new connection to the MySQL server
                require "calendarconnect.php";
                
                //chained PHP functions
                $client = $mysqli->query("SELECT client FROM appointments WHERE ID = $results")->fetch_object()->client;
                print  $client; //output value
                
                $mysqli->close();
                

                連接到數據庫代碼類似于下面

                Connection To Database Code is similar to the below

                <?php
                //Open a new connection to the MySQL server
                $mysqli = new mysqli('localhost','some database','some password','some username');
                
                //Output any connection error
                if ($mysqli->connect_error) {
                    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
                }
                

                推薦答案

                這沒有經過測試,但我認為它會像這樣.

                This isn't tested, but I think it would go something like this.

                <?php
                
                $dbc1 = new MySQLi()or die('error connecting to database');
                $dbc2 = new MySQLi()or die('error connecting to database');
                
                
                
                //build query 1
                $query1 = "SELECT * FROM Table";
                
                $result1 = $dbc1->query($query) or die("Error in query");
                $thing1 = '';
                // check result
                if($result1->num_rows){
                    //fetch result as object
                    $row = $result1->fetch_object();
                
                    //set attributes
                    $thing1 = $row->Name;
                }   
                
                
                //build query 2
                $query2 = "SELECT * FROM AnotherTable WHERE Id = '$thing1'";
                
                $result2 = $dbc2->query($query) or die("Error in query");
                $thing2 = '';
                // check result
                if($result2->num_rows){
                    //fetch result as object
                    $row = $result2->fetch_object();
                
                    //set attributes
                    $thing2 = $row->Name;
                }
                
                ?>
                

                這篇關于使用 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 中保持其類型?)

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

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

                        <legend id='QVs4J'><style id='QVs4J'><dir id='QVs4J'><q id='QVs4J'></q></dir></style></legend>
                          <tbody id='QVs4J'></tbody>

                        1. 主站蜘蛛池模板: 欧美三级成人理伦 | 一本大道久久a久久精二百 欧洲一区二区三区 | 国产免费黄网 | 成人国产精品免费观看视频 | 精品欧美一区二区三区久久久 | 狠狠色狠狠色综合系列 | 欧美高清视频一区 | av手机在线 | 一区二区免费在线视频 | 羞羞免费网站 | 一区二区三区四区国产 | 人人看人人干 | 日韩久久久久久 | 四虎成人免费电影 | 久久国产精品一区二区三区 | av一区二区三区在线观看 | 国产精品免费看 | 日韩 欧美 综合 | 中文字幕不卡 | 中文字幕在线免费视频 | 2018国产大陆天天弄 | 91麻豆产精品久久久久久 | 国产精品日韩欧美一区二区三区 | 久久久久久久久久久一区二区 | 九九综合 | 欧美日韩在线观看一区 | 9色网站 | 欧美在线视频一区 | 欧美一区视频在线 | 不卡一二区 | 亚洲福利在线视频 | 久久久久久网站 | 毛片免费视频 | 日韩一区二区在线播放 | 成人在线中文字幕 | 欧美精品久久久 | 黄网站涩免费蜜桃网站 | 91看片免费| 国产欧美一区二区三区另类精品 | 欧美视频一区二区三区 | 黄色免费在线观看网址 |