给datagrid添加一个工具栏。

【php增删改查实例】第九节 - 部门管理模块(模糊查询)

效果:
【php增删改查实例】第九节 - 部门管理模块(模糊查询)
模糊查询部门名称。
接下来,在工具栏区域画一个input框:

<div >

	请输入部门名称:<input type="text" name="deptname"  />

</div>

【php增删改查实例】第九节 - 部门管理模块(模糊查询)

然后,画一个查询按钮:

<button >查询</button>

【php增删改查实例】第九节 - 部门管理模块(模糊查询)

给查询按钮添加一个点击事件,弹出一个框,提示正在查询。
【php增删改查实例】第九节 - 部门管理模块(模糊查询)

然后,看看能不能拿到输入中的值?
完整代码:
【php增删改查实例】第九节 - 部门管理模块(模糊查询)

去修改PHP文件。
【php增删改查实例】第九节 - 部门管理模块(模糊查询)
代码:

$deptname = "";


	if(isset($_POST['deptname']) && $_POST['deptname'] != null){
		$deptname = $_POST['deptname'];

	}

	$resultset = mysql_query("select * from tm_dept where 1=1 and deptname like '%$deptname%' limit $start,$rows") or die(mysql_error());

另外,查询总数的地方也要加上这个where条件。

$resultset = mysql_query("select count(*) as total from tm_dept where 1=1  and deptname like '%$deptname%'") or die(mysql_error());

下载地址:https://pan.baidu.com/s/1OXvqQwAmz7usgD4KqiUXLw

相关文章: