Table of Contents
Search form multi-condition parallel search syntax description
A practical example
Home Backend Development PHP Tutorial Search form syntax rules for Imperial CMS_PHP tutorial

Search form syntax rules for Imperial CMS_PHP tutorial

Jul 13, 2016 am 10:33 AM
Empire cms

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
GET method:/e/search/?searchget=1 /e/search/?searchget=1&keyboard=Empire&show=title
keyboard Search keyword variables
show Search field variable (multiple fields are separated by ",". The search field must be the field where the background model enables search)
classid Search column ID (if not set to unlimited, multiple columns can be opened with ",", setting the parent column will search all sub-columns)
ztid Search topic ID (if not set to unlimited, multiple topics are available "," open)
tbname Search by data table (needs to be combined with search template ID)
tempid Search template ID used (generally used in conjunction with table search)
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)
startprice and endprice Respectively are the starting price and end price of the product price (if not filled in, there is no limit)
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
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
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
myorder Sort by:
0: Sort in reverse order (default)
1: Arrange in order
andor Set the association between multi-condition queries. There are two types:
or: relationship between or (default)
and : the relationship of and
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)

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>
Copy after login

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="标题,作者">
Copy after login

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="作者">
Copy after login

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="标题,作者">
Copy after login

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="作者">
Copy after login

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>
Copy after login

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;
}
Copy after login

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 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Where is the imperial cms website map? Where is the imperial cms website map? Apr 17, 2024 am 10:48 AM

The Empire CMS sitemap can be found by accessing the config.inc.php file and checking the dositemap settings. If set to "on", sitemap is enabled. The sitemap path is located in the sitemapurl setting and can be accessed via a browser or downloaded via FTP.

Where are the settings for the mobile version of Empire CMS? Where are the settings for the mobile version of Empire CMS? Apr 17, 2024 pm 12:12 PM

The mobile settings of Empire CMS are located in the "Mobile Template" of the "Template Management" module. The specific steps include: enabling the template, selecting the application channel, editing the template content, and saving the settings.

Where is the imperial cms resource network template? Where is the imperial cms resource network template? Apr 17, 2024 am 10:00 AM

Empire CMS template download location: Official template download: https://www.phome.net/template/ Third-party template website: https://www.dedecms.com/diy/https://www.0978.com.cn /https://www.jiaocheng.com/Installation method: Download template Unzip template Upload template Select template

Where can I put the empire cms template file for easy use? Where can I put the empire cms template file for easy use? Apr 17, 2024 am 07:22 AM

The ideal location for the Empire CMS template file is /e/template/default/skin/default/. Secondly, it can also be placed in /e/data/skins/ and /e/skin/. You need to pay attention to maintaining the folder structure and setting file permissions. and regular backups.

Where to find the empire cms database configuration file Where to find the empire cms database configuration file Apr 17, 2024 am 06:42 AM

The Imperial CMS database configuration file is located in the website root directory e/config/db.inc.php. It contains the following configuration information: $dbhost: database server address $dbuser: database user name $dbpass: database password $dbname: database name $dbport :Database port $dbcharset: Database character set

Is empire cms free? Is empire cms free? Apr 17, 2024 am 11:24 AM

Yes, Empire CMS is a free and open source content management system (CMS). It is a lightweight CMS that is feature-rich and easy to use. Empire CMS is licensed under the GNU General Public License (GPL), which means it is free to download, install and use. For commercial use, it offers a paid version that offers additional features and support such as ad management, online payments, and premium technical support.

Where is the automatic publishing interface of Empire CMS? Where is the automatic publishing interface of Empire CMS? Apr 17, 2024 am 09:03 AM

The automatic publishing interface of Empire CMS is located at /e/api/web/postinfo.php. The usage steps are as follows: visit /e/api/web/postinfo.php address and use HTTP POST to submit the article title, column ID, category ID, author and article The content and other data interfaces will return a response in JSON format, which contains the publishing results and article ID.

Where is the Imperial CMS member center? Where is the Imperial CMS member center? Apr 17, 2024 am 04:45 AM

The Imperial CMS Member Center is located in the "Member Management" menu in the background or at the following URL: Browser side: https://your domain name/e/member/user.php Server side: /e/member/user.php Functions included in the Member Center Including member management, member group management, personal center, points management, level management, etc., to facilitate administrators and members to manage website account information.

See all articles