thinkphp模糊查询实例
前端:
样式随便放
<style type="text/css">
.searchinput{
border-right-width: 0px;
padding-left: 3px;
width: 168px;
font-family: arial;
float: left;
border-top-width: 0px;
border-bottom-width: 0px;
color: #636365;
margin-left: 4px;
font-size: 8pt;
vertical-align: middle;
border-left-width: 0px;
margin-right: 3px;
}
.tab_search{
border-bottom: #cccccc 1px solid;
border-left: #cccccc 1px solid;
height: 25px;
border-top: #cccccc 1px solid;
border-right: #cccccc 1px solid;
}
.searchaction{
width: 21px;
float: left;
height: 17px;
}
</style>
下面是form表单
<form action="{:U("Admin/Statistics/money_list")}" name="search" method="post">
<table border="0" align="center" cellpadding="0" cellspacing="0" class="tab_search">
<tr>
<td>
<input type="text" title="Search" class="searchinput" id="searchinput" onkeydown="if (event.keyCode==13) {}" onblur="if(this.value=="")value="- 按订单号或用户名查询 -";" onfocus="if(this.value=="- 按订单号或用户名查询 -")value="";" value="- 按订单号或用户名查询 -" size="10" name="search"/>
</td>
<td>
<input type="image" width="21" height="17" class="searchaction" onclick="if(document.forms["search"].searchinput.value=="- 按订单号或用户名查询 -")document.forms["search"].searchinput.value="";" alt="Search" src="__PUBLIC__/assets/Admin/images/magglass.gif" border="0"
hspace="2"/>
</td>
</tr>
</table>
</form>
后台:
//得到所有的竞价列表
public function money_list(){
$demo=M("chuanbo");
$money_list=$demo->table("bo_account_log a,bo_user b")->where("a.user_id=b.id")->order("a.id desc" )->select();
$search = I("post.search");
if(IS_POST){
$where["order_no"] = array("like","%".$search."%");
$money_list =$demo->table("bo_account_log a,bo_user b")->where("a.user_id=b.id and (a.order_no like "%$search%" or user_name like "%$search%") ")->select();
}else{
$money_list=$demo->table("bo_account_log a,bo_user b")->where("a.user_id=b.id")->order("a.id desc" )->select();
}
$user=M("user");
$this->assign("money_list",$money_list);
$this->display();
}
}
- 上一篇: thinkphp 解析带html标签的内容
- 下一篇:没有了