码迷,mamicode.com
首页 > 数据库 > 详细

一页php里连多个ms数据库

时间:2014-12-15 17:00:21      阅读:262      评论:0      收藏:0      [点我收藏+]

标签: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 ="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>";
}
?>

 

一页php里连多个ms数据库

标签:style   blog   io   ar   color   os   sp   for   on   

原文地址:http://www.cnblogs.com/hellowzd/p/4164935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!