查询提交表单后的问题
请问以下这段搜索的代码那边出了错?
当我txtName没有填写内容,提交表单的时候,
sql语句还是只执行最后一个sql语句,即select * from material order by Mat_id,
而我要的效果是它应该执行第一条语句,即select * from material where Mat_name like '%$name%' and Mat_category in ($category)
当我txtName没有填写内容,提交表单的时候,
sql语句还是只执行最后一个sql语句,即select * from material order by Mat_id,
而我要的效果是它应该执行第一条语句,即select * from material where Mat_name like '%$name%' and Mat_category in ($category)
<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])){
?>
...全文
相关推荐
JSP中的FORM表单中只有一个input文本时,按回车键将会自动提交表单
一个列表界面只有一个输入框查询条件,当首次进入在输入框中输入汉字后,按回车键发现输入框中汉字变成乱码!本以为一个很简单不过的问题,结果却花了好久才找到原因(据说是浏览器问题),按回车后执行了两次查询。 1、未修改前代码: <form id=ff name=ff method=post> <input type=text id=userName name=userName size=12 maxlength='30' value=${(data.userName)!''} onKeypress= [removed]if(event.keyCode==1
使用get方式提交表单在地址栏里面不显示提交信息
主要介绍了使用get方式提交表单在地址栏里面不显示提交信息的相关资料,需要的朋友可以参考下
PHP程序设计-3期(KC016) 5.2.5条件查询常见问题.docx
PHP程序设计-3期(KC016) 5.2.5条件查询常见问题.docx 学习资料 复习资料 教学资源
防止用户表单重复提交处理
防止用户表单重复提交的完整demo 分别在js与后台中处理,js处理(针对网络慢情况) 后台处理(针对用户点击浏览器上的刷新按钮等)
PHP程序设计-3期(KC016) 5.1.5条件查询常见问题.docx
PHP程序设计-3期(KC016) 5.1.5条件查询常见问题.docx 学习资料 复习资料 教学资源


基础编程
