Home >Backend Development >PHP Tutorial >Example of how to remember status when searching in PHP
This article mainly introduces the method of remembering the status when searching in PHP. It analyzes the related operation skills of PHP through get parameter transfer and DOM element form to record the search status in the form of examples. It has certain reference value. Friends in need You can refer to the following
The example of this article describes the method of remembering the state when searching in PHP. Share it with everyone for your reference, the details are as follows:
<!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>
Additional:
In addition, it is also important to note that ordinary The GET request is in the form: http://yourWebname.com/index.php?ids=1&ids=2 You can pass the corresponding single parameter
and use the form like :http://test.tmp/index.php?ids[]=1&ids[]=2 can be passed in the form of array parameters
Related recommendations:
php implements classes and methods for sorting names according to initial letters
PHP implements login verification code verification Function
The above is the detailed content of Example of how to remember status when searching in PHP. For more information, please follow other related articles on the PHP Chinese website!