为什么一直运行不出结果?


查询

学号:

学院:


<?php
//error_reporting(E_ALL ^E_NOTICE);
$usersname=trim($_POST['usersname']);
$xueyuan=trim($_POST['xueyuan']);

if($usersname!= null){
$a = " and 学号或工号='$usersname'";}

if($xueyuan!= null){
$b = " and 院系='$xueyuan' ";}

$q = "select *from users where 1=1";
$q.=$a;
$q.=$b;
echo $q;

$link=mysqli_connect('localhost','root','123456');
mysqli_select_db($link,'schoolll');
mysqli_set_charset ($link,'utf8');
$rs = mysqli_query($link,$q);

if($rs)
echo "成功";
else
echo "失败";
echo "

";
echo "";
while($row = mysqli_fetch_assoc($rs)) {
echo "";
}
echo "
学号或工号姓名
$row['学号或工号']$row['院系']
";

mysqli_close($link);

?>

总是 从query那句就返回false,即使返回成功了也不能输出$row['学号或工号']、$row['院系'],数据库连接没问题,我试过了。求大神解答!!!
/*

echo '

';
foreach($row as $data){
echo ''.$data.'';
}
echo '';
*/
还有用这一段替换while里面的内容,query中搜索"select *from users where 1=1",出了结果,但是是乱码,可是我数据库已经设置成utf8了啊。。。

调试下,看看哪里错了。