本文实例讲述了php实现搜索时记住状态的方法。分享给大家供大家参考,具体如下:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>php of search remember state</title></head><!--方式一 模版获取get参数方式记住条件--><php>$start = $_get['start'];$end = $_get['end'];</php><!--方式二 dom加载方式传递条件--><php>$search = $_get['search'];</php><script type='text/javascript'>//dom加载结束$(function(){{if:$this->search}var searchdata = {echo:json::encode($this->search)};for(var index in searchdata){$('[name="search['+index+']"]').val(searchdata[index]);}{/if}});</script><body><!--方式一 模版获取get参数方式记住条件-->时间:<input type="text" name='start' value='{$start}' /> —— <input type="text" value="{$end}" name='end' /><!--方式二 dom加载方式传递条件-->姓名:<input name="search[username]" type="text" value="" />电话:<input name="search[telphone]" type="text" value="" /></body></html>
补充:
此外还需要注意,普通的get请求形如:http://yourwebname.com/index.php?ids=1&ids=2 可传递对应的单个参数
而使用形如:http://test.tmp/index.php?ids[]=1&ids[]=2 的形式可传递数组参数
您可能感兴趣的文章:laravel项目利用twemproxy部署redis集群的完整步骤php实例
php7如何开启opcode打造强悍性能详解php技巧
php基于递归算法解决兔子生兔子问题php技巧
以上就是php实现搜索时记住状态的方法示例_php技巧的详细内容。
