pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="czsoid8" 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="xfcuvuf" 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="3ydclg8" 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. 主站蜘蛛池模板: 上海璟文空运首页_一级航空货运代理公司_机场快递当日达 | 房车价格_依维柯/大通/东风御风/福特全顺/江铃图片_云梯搬家车厂家-程力专用汽车股份有限公司 | 微动开关厂家-东莞市德沃电子科技有限公司 | 自动售货机_无人售货机_专业的自动售货机运营商_免费投放售货机-广州富宏主官网 | 爱佩恒温恒湿测试箱|高低温实验箱|高低温冲击试验箱|冷热冲击试验箱-您身边的模拟环境试验设备技术专家-合作热线:400-6727-800-广东爱佩试验设备有限公司 | 海峰资讯 - 专注装饰公司营销型网站建设和网络营销培训 | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 | 科昊仪器超纯水机系统-可成气相液氮罐-美菱超低温冰箱-西安昊兴生物科技有限公司 | 浙江上沪阀门有限公司 | 上海深蓝_缠绕机_缠膜机-上海深蓝机械装备有限公司 | 伸缩器_伸缩接头_传力接头-巩义市润达管道设备制造有限公司 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | MES系统工业智能终端_生产管理看板/安灯/ESOP/静电监控_讯鹏科技 | 广东护栏厂家-广州护栏网厂家-广东省安麦斯交通设施有限公司 | 诗词大全-古诗名句 - 古诗词赏析 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 润滑油加盟_润滑油厂家_润滑油品牌-深圳市沃丹润滑科技有限公司 琉璃瓦-琉璃瓦厂家-安徽盛阳新型建材科技有限公司 | 汽车水泵_汽车水泵厂家-瑞安市骏迪汽车配件有限公司 | 活性氧化铝球|氧化铝干燥剂|分子筛干燥剂|氢氧化铝粉-淄博同心材料有限公司 | 字典-新华字典-在线字典查字-字典趣 | 刚性-柔性防水套管-橡胶伸缩接头-波纹管补偿器-启腾供水材料有限公司 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 上海深蓝_缠绕机_缠膜机-上海深蓝机械装备有限公司 | 温州食堂承包 - 温州市尚膳餐饮管理有限公司 | 超声波乳化机-超声波分散机|仪-超声波萃取仪-超声波均质机-精浩机械|首页 | 报警器_家用防盗报警器_烟雾报警器_燃气报警器_防盗报警系统厂家-深圳市刻锐智能科技有限公司 | 华禹护栏|锌钢护栏_阳台护栏_护栏厂家-华禹专注阳台护栏、楼梯栏杆、百叶窗、空调架、基坑护栏、道路护栏等锌钢护栏产品的生产销售。 | PCB厂|线路板厂|深圳线路板厂|软硬结合板厂|电路板生产厂家|线路板|深圳电路板厂家|铝基板厂家|深联电路-专业生产PCB研发制造 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 粉末包装机-给袋式包装机-全自动包装机-颗粒-液体-食品-酱腌菜包装机生产线【润立机械】 | FAG轴承,苏州FAG轴承,德国FAG轴承-恩梯必传动设备(苏州)有限公司 | 除尘器布袋骨架,除尘器滤袋,除尘器骨架,电磁脉冲阀膜片,卸灰阀,螺旋输送机-泊头市天润环保机械设备有限公司 | 公交驾校-北京公交驾校欢迎您! 工作心得_读书心得_学习心得_找心得体会范文就上学道文库 | 杭州公司变更法人-代理记账收费价格-公司注销代办_杭州福道财务管理咨询有限公司 | 航空铝型材,7系铝型材挤压,硬质阳*氧化-余润铝制品 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-沼河浸过滤器 | 旋振筛_不锈钢旋振筛_气旋筛_旋振筛厂家—新乡市大汉振动机械有限公司 | 复合土工膜厂家|hdpe防渗土工膜|复合防渗土工布|玻璃纤维|双向塑料土工格栅-安徽路建新材料有限公司 | 北京自然绿环境科技发展有限公司专业生产【洗车机_加油站洗车机-全自动洗车机】 | CE认证_FCC认证_CCC认证_MFI认证_UN38.3认证-微测检测 CNAS实验室 | 天一线缆邯郸有限公司_煤矿用电缆厂家_矿用光缆厂家_矿用控制电缆_矿用通信电缆-天一线缆邯郸有限公司 |