標籤:style blog io ar color os sp for on
<?php/*添加指令碼參數:u=使用者名稱v=城市名為使用者添加城市標籤*/header("Content-Type:text/html; charset=utf-8");/*$server ="123.7.63.176"; //伺服器IP地址,如果是本地,可以寫成localhost$uid ="nxtyjs"; //使用者名稱$pwd ="[email protected]#"; //密碼$database ="AAA"; //ms資料庫名稱$conn =mssql_connect($server,$uid,$pwd) or die ("connect failed");mssql_select_db($database,$conn);*///get傳值$u=$_POST[‘u‘];$v=$_POST[‘v‘];/*//顯示my裡的使用者資料以便於添加參照$a=$cnx->query("SELECT * FROM ofgroupuser");foreach($a as $b) {//print_r ($myrow);//echo "<br>";echo "-------------------------------------";echo "<br>";echo "openfire裡的使用者名稱>>>>>";var_dump($b); print_r ($a[‘username‘]);echo "<br>";echo "-------------------------------------";}*/$cnx = new PDO("odbc:Driver={SQL Server};Server=123.7.63.176;Database=Openfire;",‘nxtyjs‘,‘[email protected]#‘); //建立第一個串連$a=$cnx->query("SELECT * FROM ofgroupuser");foreach($a as $b) { echo "-------------------------------------";echo "<br>";echo "openfire裡的使用者名稱>>>>>";//var_dump($b); print_r ($b[‘username‘]);echo "<br>";echo "-------------------------------------"; }echo "<br>";echo "<br>";echo "||||||||||||||||||||||||||||||||||||||||||||||添加城市標籤||||||||||||||||||||||||||||||||||||||||||||||||||";echo "<br>";echo "<br>";echo "<br>";echo "<form name=‘form‘ method=‘post‘ action=‘‘>";echo "使用者:<input type=‘text‘ name=‘u‘>";echo " ";echo "城市標籤:<input type=‘text‘ name=‘v‘>";echo " ";echo "<input type=‘submit‘ value=‘提交‘>";echo "</form>";echo "<br>";echo "|||||||||||||||||||||||||||||||擴充資料庫裡的資料||||||||||||||||||||||||||||||||||||||";echo "<br>";echo "<br>";//print_r ($u);//print_r ($v);/*//查詢my裡關鍵字所在行的資料$hang=$result = mysql_query("SELECT * FROM ofgroupuser WHERE username LIKE ‘".$u."‘ ");//向ms裡迴圈插入my行資料和get值while($row = mysql_fetch_array($hang)) {$query123 ="INSERT INTO guanlian (uer,goup,visty) VALUES (N‘".$row[‘username‘]."‘,N‘".$row[‘groupName‘]."‘,‘".$v."‘)";$haha=mssql_query($query123); }*///查詢ms結果$cnx = new PDO("odbc:Driver={SQL Server};Server=123.7.63.176;Database=AAA;",‘nxtyjs‘,‘[email protected]#‘); //建立第二個串連$row=$cnx->query("SELECT * FROM guanlian");foreach($row as $list){echo "----------------------------------------------------------------------------------";echo "<br>"; echo "id:"; print_r($list[‘id‘]); echo"|"; echo " "; echo "使用者:"; print_r($list[‘uer‘]); echo"|"; echo " "; echo "分組:"; print_r($list[‘goup‘]); echo"|"; echo " "; echo "城市:"; print_r($list[‘visty‘]); echo"|"; echo " "; echo "<br>"; echo "----------------------------------------------------------------------------------";echo "<br>";}?>
一頁php裡連多個ms資料庫