首页 > 代码库 > stos

stos

add

<?php/*添加脚本参数:u=用户名v=城市名为用户添加城市标签*/header("Content-Type:text/html; charset=utf-8");$server ="(local)";  //服务器IP地址,如果是本地,可以写成localhost$uid ="sa";  //用户名$pwd ="123456"; //密码$database ="AAA";  //ms数据库名称$conn =mssql_connect($server,$uid,$pwd) or die ("connect failed");mssql_select_db($database,$conn);//进行my数据库连接$con = mysql_connect("localhost","root","root");if (!$con)  {  die(‘Could not connect: ‘ . mysql_error());  }mysql_query("set names utf8");//ut8声明mysql_select_db("openfire", $con);//打开my里的数据库//get传值$u=$_GET[‘u‘];$v=$_GET[‘v‘];//显示my里的用户数据以便于添加参照$my = mysql_query("SELECT * FROM ofgroupuser");while($myrow = mysql_fetch_array($my))  {print_r ($myrow);echo "<br>";  }echo "<br>";echo "<br>";echo "<br>";//查询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结果$query ="select * from guanlian";$row =mssql_query($query);while($list=mssql_fetch_array($row)){       print_r($list);       echo "<br>";}?>

del

<?php/*删除脚本id为ms里的idid=id值u=用户名通过id值删除对应的条例通过用户名删除用户相关所有的数据v=城市名通过城市名删除城市相关所有的数据*/header("Content-Type:text/html; charset=utf-8");$server ="(local)";  //服务器IP地址,如果是本地,可以写成localhost$uid ="sa";  //用户名$pwd ="123456"; //密码$database ="AAA";  //ms数据库名称$conn =mssql_connect($server,$uid,$pwd) or die ("connect failed");mssql_select_db($database,$conn);//get传值$id=$_GET[‘id‘];$u=$_GET[‘u‘];$v=$_GET[‘v‘];//根据id删除$iddel = "DELETE FROM guanlian WHERE id = ".$id."";@mssql_query($iddel);$udel = "DELETE FROM guanlian WHERE uer = ‘".$u."‘";@mssql_query($udel);$vdel = "DELETE FROM guanlian WHERE visty = ‘".$v."‘";@mssql_query($vdel);print_r ($v);echo "<br>";print_r ($vdel);echo "<br>";//查询ms结果$query ="select * from guanlian";$row =mssql_query($query);while($list=mssql_fetch_array($row)){       print_r($list);       echo "<br>";}?>

select

<?php/*查询脚本参数:g=组名 专家或者领导等v=城市名 查找鹤壁市里所有的专家msu=ms数据库里的用户根据msu查询my里的用户,如果用户不存在,则删除ms里的用户*/header("Content-Type:text/html; charset=utf-8");$server ="(local)";  //服务器IP地址,如果是本地,可以写成localhost$uid ="sa";  //用户名$pwd ="123456"; //密码$database ="AAA";  //ms数据库名称$conn =mssql_connect($server,$uid,$pwd) or die ("connect failed");mssql_select_db($database,$conn);//进行my数据库连接$con = mysql_connect("localhost","root","root");if (!$con)  {  die(‘Could not connect: ‘ . mysql_error());  }mysql_query("set names utf8");//ut8声明mysql_select_db("openfire", $con);//打开my里的数据库//显示my里的用户数据以便于添加参照$my = mysql_query("SELECT * FROM ofgroupuser");while($myrow = mysql_fetch_array($my))  {print_r ($myrow);echo "<br>";  }echo "<br>";echo "<br>";//get传值$g=$_GET[‘g‘];$v=$_GET[‘v‘];$msu=$_GET[‘msu‘];/*比如我知道ms里存在一个用户,但是我不知道在my里这个用户是否还存在那么ms里的这个用户就是一个参数,我根据这个参数去my里查询,如果不存在那么删除这个参数对应的ms里的所有数据这是手动的方法,需要人工一条一条的验证*/$msmy = mysql_query("SELECT username FROM ofgroupuser where username = ‘".$msu."‘");@$eq = mysql_fetch_array($msmy);//判断开始 这里默认该字段为 nameif(!empty($eq[‘username‘])){      echo "不为空";    }else{          $udel = "DELETE FROM guanlian WHERE uer = ‘".$msu."‘";@mssql_query($udel);        }/*自动反查询、自动删除测试*/$s ="select uer from guanlian";//查找关联表里的用户@$ss =mssql_query($s);//把查找语句放入ms里执行while($go=@mssql_fetch_array($ss))//循环遍历出用户{$sql="SELECT username FROM ofgroupuser where username = ‘".$go[‘uer‘]."‘";//把循环遍历出来的用户放入my里进行用户查询$msmy = mysql_query($sql);//把查询语句放入my里执行while($mysql = @mysql_fetch_array($msmy))//循环遍历出my里的用户,到了这里,用户只能是my和ms共有的  {$ok="DELETE FROM guanlian WHERE uer <> ‘".$go[‘uer‘]."‘";//删除ms里与my不共有的用户@mssql_query($ok);//在ms里执行删除命令  }}/*自动反查询、自动删除测试*///查询ms结果,城市和分组结果集$sql ="select * from guanlian where visty= ‘".$v."‘ and goup=‘".$g."‘ ";@$mssql =mssql_query($sql);while($display=@mssql_fetch_array($mssql)){    print_r ($sql);       print_r($display);       echo "<br>";}echo "<br>";echo "<br>";//查询ms结果,所有数据的结果集$query ="select * from guanlian";$row =mssql_query($query);while($list=mssql_fetch_array($row)){       print_r($list);       echo "<br>";}?>

 

stos