Home >Backend Development >PHP Tutorial >Search form syntax rules for Imperial CMS_PHP tutorial

Search form syntax rules for Imperial CMS_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:33:10920browse

Empire CMS provides a relatively powerful search result call. You can create most of the search functions that meet your needs according to the empire cms search form creation syntax. If you have custom fields in your database, you may need to change the data processing of e/search/index.php for form submission. You can refer to the example provided at the end of the article. Let’s take a look at the search form variable description first:

Variable name Description Example
Search form submission address POST method: /e/search/index.php 1dde0be3394c8e9cc725777a7cd8b64b
GET method:/e/search/?searchget=1 /e/search/?searchget=1&keyboard=Empire&show=title
keyboard Search keyword variables 897a4e30673868d7e631e21e733aca96
show Search field variable (multiple fields are separated by ",". The search field must be the field where the background model enables search) 5b38ff1a3747b2875192d1874be8c0ad
classid Search column ID (if not set to unlimited, multiple columns can be opened with ",", setting the parent column will search all sub-columns) d1fbb67de94a0e38acec8dafbb33fef4
ztid Search topic ID (if not set to unlimited, multiple topics are available "," open) 45bb6cae8150a37f1a1e6f06cc953bdb
tbname Search by data table (needs to be combined with search template ID) 0b677af8092477481346f0444f684409
tempid Search template ID used (generally used in conjunction with table search) 98c4d5aaf7c6580d243e289567f2b38a
starttime and endtime Respectively search for information about the start time and end time of publishing (if not filled in, there is no limit. Format: 2008-02-27) 90ea4c52ec55f1d661440bc7169172a5
8bf2322c60b328c3fc0ecf370467f76f
startprice and endprice Respectively are the starting price and end price of the product price (if not filled in, there is no limit) 6d311362d2cd6b085f4b1594e773eae2
697c19c71c8765b4e1feb97d29fa3e18
Search special fields id: Search by message ID
keyboard: Search by keyword (can list information by tags)
userid : Search by publisher user ID
username: Search by publisher username
e86802fd8e5dce685c0bbdb74def1a6d
member If the value is 0, there is no limit
A value of 1 means only searching for information submitted by members
If the value is 2, only the information added by the administrator will be searched
3b66187ac135f3bb5f252c266ef47169
orderby Sort field:
0: By release date (default)
1: Press ID
2: By number of comments
3: Click to browse popularity
4: According to the number of downloads
8c46df2875eb1e2b6dd189ae069a72d2
myorder Sort by:
0: Sort in reverse order (default)
1: Arrange in order
53c91e34d1c4cd56208a1d79904a6fa1
andor Set the association between multi-condition queries. There are two types:
or: relationship between or (default)
and : the relationship of and
d2b84a5075b8705f58a3569f2ce11c15
hh Logical operation connector variable:
LT : less than
GT : Greater than
EQ : equal to
LE : less than or equal to
GE: greater than or equal to
NE : Not equal to
IN : Contains (search keywords separate each value with a space)
BT: Range, between two values ​​(search keywords separate two values ​​with a space)
LK: Fuzzy query (default)
f1632e9ccd8bed75386bd310a2dfaea3

Here is an example:

<table width="320" border="0" cellspacing="1" cellpadding="3">
<form name="searchform" method="post" action="/e/search/index.php">
<tr>
   <td>关键字:<input name="keyboard" type="text" size="10"></td>
   <td>范围:
      <select name="show">
      <option value="title">标题</option>
      <option value="smalltext">简介</option>
      <option value="newstext">内容</option>
      <option value="writer">作者</option>
      <option value="title,smalltext,newstext,writer">搜索全部</option>
       </select></td>
</tr>
<tr>
   <td>栏 目:
      <select name="classid">
      <option value="0">搜索全部</option>
      <option value="1">新闻中心</option>
      <option value="4">技术文档</option>
      <option value="22">下载中心</option>
       </select> </td>
   <td><input type="submit" name="submit" value="搜索"></td>
</tr>
</form>
</table>

Search form multi-condition parallel search syntax description

1. Multi-field parallel search: There are two transmission methods: "string" and "array"

String passing as example:

<input type="hidden" name="hh" value="LK">
<input type="hidden" name="show" value="title,writer">
<input type="hidden" name="keyboard" value="标题,作者">

Note: The above is a fuzzy query for information that the title field contains the "title" character or the writer field contains "author"

Array passing as example:

<input type="hidden" name="hh" value="LK">
<input type="hidden" name="show[]" value="title">
<input type="hidden" name="keyboard[]" value="标题">
<input type="hidden" name="show[]" value="writer">
<input type="hidden" name="keyboard[]" value="作者">

The above is a fuzzy query for information that the title field contains the "title" character or the writer field contains "author"

2. Parallel search of multiple logical operation connectors

String passing as example:

<input type="hidden" name="hh" value="LK,EQ">
<input type="hidden" name="show" value="title,writer">
<input type="hidden" name="keyboard" value="标题,作者">

Explanation: The above is a fuzzy query for information that the title field contains the "title" character or the writer field is equal to "author"

String passing as example:

<input type="hidden" name="show[]" value="title">
<input type="hidden" name="hh[]" value="LK">
<input type="hidden" name="keyboard[]" value="标题">
<input type="hidden" name="show[]" value="writer">
<input type="hidden" name="hh[]" value="EQ">
<input type="hidden" name="keyboard[]" value="作者">

Explanation: The above is a fuzzy query for information that the title field contains the "title" character or the writer field is equal to "author".

A practical example

The form design is as follows:

						<form action="[!--news.url--]e/search/index.php" method="post" name="searchform" id="searchform">
						<select name="classid" id="" style="display:none">
							<option value="59,60,78,79,80,81" selected>全部</option>
						</select>
						<input type="hidden" name="show" value="title,myarea,mycategory,smalltext" />
						<input type="hidden" name="tempid" value="1" />
						<table width="100%" cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr class="even">
									<td style=" text-align:left;">地区:
								<select name="area" id="">
									<option value="">不限</option>
									<option value="香洲">香洲</option>
									<option value="吉大">吉大</option>
									<option value="拱北">拱北</option>
									<option value="新香洲">新香洲</option>
									<option value="前山">前山</option>
									<option value="南屏">南屏</option>
									<option value="金湾">金湾</option>
									<option value="斗门">斗门</option>
								</select>
								
								  房型:
								<select name="category" id="">
									<option value="">不限</option>
									<option value="58_0">一房</option>
									<option value="58_1">二房</option>
									<option value="58_2">三房以上</option>
									<option value="58_3">公寓</option>
									<option value="58_4">写字楼</option>
									<option value="58_5">商铺</option>
									<option value="58_6">厂房</option>
								</select>
									</td>
									<td> </td>
								</tr>
								<tr class="even">
									<td style=" text-align:left;">时间范围: <input name="starttime" type="text" value="2008-08-08" size="12" onclick="calendar.show(this);" /> 到 <input type="text" id="todayButton" name="todayButton" value="" size="12" onclick="calendar.show(this);" /> (不选则不限时段)</td>
									<td> </td>
								</tr>
								<tr class="even">
									<td style=" text-align:left;"><input name="keyboard" type="text" size="32" value="" id="keyboard" class="inputText" />   <input type="submit" name="Submit22" value=" 搜 索 " /></td>
									<td></td>
								</tr>
							</tbody>
						</table>
						</form>

In order to add the search for the custom fields myarea and mycategory, we need to rewrite e/search/index.php appropriately:

$keyboard=$_POST['keyboard'].','.$_POST['area'].','.$_POST['category'];
// 这是原来的:$keyboard=$_POST['keyboard'];
$keyboardone=0;
if(is_array($keyboard))
{}
elseif(strstr($keyboard,','))
{
	$keyboard=explode(',',$keyboard);
}
else
{
	$keyboard=trim($keyboard);
	$len=strlen($keyboard);
	if($len<$public_r[min_keyboard]||$len>$public_r[max_keyboard])
	{
		printerror("MinKeyboard",$getfrom,1);
	}
	$keyboardone=1;
}

OK, done.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/752538.htmlTechArticleEmpire CMS provides a relatively powerful search result call. You can follow the empire cms search form production syntax to create a satisfying Most of the search functionality you need. If you have in your database...
Statement:
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