一页php里连多个ms数据库

<?php
/*
添加脚本
参数:u=用户名
v=城市名
为用户添加城市标签
*/


header("Content-Type:text/html; charset=utf-8");
/*
$server ="123.7.63.176";  //服务器IP地址,如果是本地,可以写成localhost
$uid ="nxtyjs";  //用户名
$pwd ="nxtyjs123456!@#"; //密码
$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‘,‘nxtyjs123456!@#‘); //建立第一个连接
$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 "&nbsp;&nbsp;";
echo "城市标签:<input type=‘text‘ name=‘v‘>";
echo "&nbsp;&nbsp;";
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‘,‘nxtyjs123456!@#‘); //建立第二个连接
$row=$cnx->query("SELECT * FROM guanlian");
foreach($row as $list)
{
echo "----------------------------------------------------------------------------------";
echo "<br>";
       echo "id:";
       print_r($list[‘id‘]);
       echo"|";
         echo "&nbsp;&nbsp;";
         echo "用户:";
         print_r($list[‘uer‘]);
       echo"|";
       echo "&nbsp;&nbsp;";
       echo "分组:";
       print_r($list[‘goup‘]);
       echo"|";
       echo "&nbsp;&nbsp;";
       echo "城市:";
       print_r($list[‘visty‘]);
       echo"|";
       echo "&nbsp;&nbsp;";
       echo "<br>";
     
echo "----------------------------------------------------------------------------------";
echo "<br>";
}
?>

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。