Home  >  Article  >  Backend Development  >  php mssql查询的一个有关问题(请问)

php mssql查询的一个有关问题(请问)

WBOY
WBOYOriginal
2016-06-13 11:29:17703browse

php mssql查询的一个问题(请教)
//获得整列的所有值,转为一个2维数组。
function getAll($sql) {
    $query=mssql_query($sql);
    if($query) {
        $temp=array();
        while($res=mssql_fetch_assoc($query)) {
            $temp[]=$res;
        }
        return $temp;
    }
    else{
    return false;
    }
}
$result ="SELECT zdmc FROM QX WHERE jsid=9 and tcmc='$ditcbo' and kj=1";
$arr=getALL($result);
//把二维数组转为一个用单引加逗号隔开的字符串
for($i=0;$i$array[] = $arr[$i]["zdmc"];
}
$r="'".implode("','", $array )."'";
//用这个字符串在表中进行查询
$result2 = mssql_query("SELECT $r FROM $sjb WHERE ID='$bh'");
$row = mssql_fetch_array($result2);
print_r($row)
显示的结果为


乱码是因为这个是读的是mmsql的gbk编码,用到的时候我会进行转换,但是现在里面读到的内容都是不正确的
新手写弄的,求兄弟帮忙啊

PHP MS?SQL select
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn