21,886
社区成员
发帖
与我相关
我的任务
分享
<form action="?action=search" method="post" name="form1" id="form1">
<p>物料名称:
<input name="txtName" type="text" id="txtName" value="" />
类别:
<select name="sltCategory" id="sltCategory" onchange="document.getElementById('txtCategory').value=document.getElementById('sltCategory').value">
<option value="">无</option>
<option value="0">耗材</option>
<option value="1">电脑</option>
<option value="2">其他设备</option>
</select><input name="txtCategory" type="text" id="txtCategory" size="10" value="0,1,2" />
<input name="btnSearch" type="submit" id="btnSearch" value=" 查询 " />
</form>
<?php
$class = 'action=search&txtName='.$_REQUEST['txtName'].'&txtCategory='.$_REQUEST['txtCategory'];
echo $class."<br>";
if($_REQUEST['txtName']&&$_REQUEST['action']=="search"){
$name = $_REQUEST['txtName'];
$category = $_REQUEST['txtCategory'];
if($name == null){
$sql = "select * from material where Mat_category in ($category) order by Mat_id";
}else
$sql= "select * from material where Mat_name like '%$name%' and Mat_category in ($category)";
}else{
$sql = "select * from material order by Mat_id";
}
echo $sql;
$page = page($db,$sql,5,$class);
while($row=mysql_fetch_array($page[0])){
?>
<?php
$class = 'action=search&txtName='.$_REQUEST['txtName'].'&txtCategory='.$_REQUEST['txtCategory'];
echo $class."<br>";
if($_REQUEST['action']=="search"){
$name = $_REQUEST['txtName'];
$category = $_REQUEST['txtCategory'];
if($name == null){
$sql = "select * from material where Mat_category in ($category) order by Mat_id";
}else
$sql= "select * from material where Mat_name like '%$name%' and Mat_category in ($category)";
}else{
$sql = "select * from material order by Mat_id";
}
echo $sql;
?>
if($_REQUEST['action']=="search")
{
if($_REQUEST['txtName'])
{
$sql= "select * from material where Mat_name like '%$name%' and Mat_category in ($category)";
}
else
{
$sql = "select * from material where Mat_category in ($category) order by Mat_id";
}
}
else
{
$sql = "select * from material order by Mat_id";
}