Example of how to remember status when searching in PHP

不言
Release: 2023-03-29 07:10:01
Original
1252 people have browsed it

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[&#39;start&#39;];
$end = $_GET[&#39;end&#39;];
</php>
<!--方式二 DOM加载方式传递条件-->
<php>
$search = $_GET[&#39;search&#39;];
</php>
<script type=&#39;text/javascript&#39;>
//DOM加载结束
$(function(){
{if:$this->search}
var searchData = {echo:JSON::encode($this->search)};
for(var index in searchData)
{
$(&#39;[name="search[&#39;+index+&#39;]"]&#39;).val(searchData[index]);
}
{/if}
});
</script>
<body>
<!--方式一 模版获取GET参数方式记住条件-->
时间:<input type="text" name=&#39;start&#39; value=&#39;{$start}&#39; /> —— <input type="text" value="{$end}" name=&#39;end&#39; />
<!--方式二 DOM加载方式传递条件-->
姓名:<input name="search[username]" type="text" value="" />
电话:<input name="search[telphone]" type="text" value="" />
</body>
</html>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!