各位大侠,我想用php做一个搜索的功能,但是有问题,帮忙看看吧,高分求助!

<form name="form1" method="post" action="select.php" onsubmit="return chkinput_search(this)">
<table width="749" height="28" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center" bgcolor="#999999" class="STYLE1">请选择查询条件:
<label>
<select name=type >
<option value="1">用户名</option>
<option value="2">所在部门</option>
</select>
</label> <label>
<input type="text" name="keyword" size="20" />
<input type="submit" name="Submit" value="查询" />
</label></td>
</tr>
<tr>
<td width="218"> </td>
<td width="531"> </td>
</tr>
</table>
</form>

<script language="javascript">
function chkinput_search(form){
if(form.type.value==""){
alert('请选择查询条件!');
form.type.focus();
return(false);
}
if(form.keyword.value==""){
alert('请输入查询关键字!');
form.keyword.focus();
return(false);
}
return(true);

}
</script>
<body>
<?
$server="localhost";//数据库服务器IP或域名
$user="root";//数据库登陆用户名
$pwd="123456";//数据库登陆密码
$database_name="ttdxx";//数据库名称

$conn=mysql_connect($server,$user,$pwd);//连接数据库
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db($database_name,$conn);//打开数据库

$type=$_POST["type"];
$keyword=$_POST["keyword"];
if($type==1)
{
$query = "SELECT * FROM `fls_users` where `reg_account` '%".$keyword."%' ";
}
else if($type==2)
{
$query = "SELECT * FROM `fls_users` where `province` like '%".$keyword."%' ";
}
//echo "$sql";
mysql_query('set names gb2312');
$result1=mysql_query($query);//执行一条数据查询
//$row=mysql_fetch_row($result);//数据显示
while($row=mysql_fetch_row($result1))
{
?>
<table width="749" height="25" border="1" align="center">
<tr>
<td width="158"><span class="STYLE1">用户名:
<?=$row[1]?>
 </span></td>
<td width="125"><span class="STYLE1">姓名:
<?=$row[5]?>
</span></td>
<td width="199"><span class="STYLE1">部门:
<?=$row[9]?>

<?=$row[10]?>
</span></td>
<td width="142"><span class="STYLE1">职位:
<?=$row[11]?>
</span></td>
<td width="132" align="center" class="STYLE1"><font color="#000000" class="STYLE1">[<a href="delete_ok.php?reg_id=<?=$row[0]?>">删除</a>]</font></a><font color="#000000">[<a href="adminUpdate.php?reg_id=<?=$row[0]?>">修改</a>]</font></td>
</tr>
</table>
<?
}
mysql_free_result($result1);
?>
</body>

1。当$type=1的时候。sql语句写错了,少了个 like。
2。<?=$...?> 这种写法需要打开php.inn中的short_open_tag。
3。('set names gb2312') 中的gb2312要加引号。//('set names “gb2312“');
大概就这些了吧。你又没有说你报什么错。
温馨提示:答案为网友推荐,仅供参考