Chapter 11 Implementation of Doking's BLOG on-site search
It is often seen that many websites have an on-site search function. How is this implemented? If it is ASP, Dreamweaver will soon be able to implement it. Now it's ASP.NET, so I have to do a little hand-coding.
11.1 SELECT Advanced Search Skills
After studying the above chapters, you will have a little understanding of SELECT. There is actually nothing mysterious about SELECT advanced search techniques. It is mainly related to the use of pattern matching operators. So here we mainly explain the use of pattern matching operators.
The pattern matching operators LIKE and NOT LIKE are often used in fuzzy searches, which determine whether the column value matches the specified string format. LIKE is used to find records that match certain conditions, and NOT LIKE is used to find records that do not match specified conditions. Can be used for string, text, date and other types of queries.
1. Percent sign %: can match any type and length of characters.
For example: SELECT study notes FROM study notes table WHERE title LIKE "Network %"
This query is to query all study notes in the study notes table whose titles begin with "Network", such as: network database ASP one-click pass, network and mobile phone communication development research wait.
For example: SELECT study notes FROM study note table WHERE title LIKE “%ASP.NET%”
This query is to query all study notes whose title contains "ASP.NET".
2. Underscore_: matches a single arbitrary character, often used to limit the character length of expressions.
For example: SELECT study notes FROM study note table WHERE title LIKE "V_Development Selection"
This query mainly searches for study notes with titles such as "VB Development Selection" and "VC Development Selection".
3. Square brackets [ ]: Specify characters, strings or ranges, and the matched object is required to be any one of them.
11.2 Implementation of the site search function
After introducing the SELECT advanced search technique, we will introduce the implementation of the site search function. Only the percent sign % pattern matching operator is used here.
(1) Open the template dkblog.dwt.aspx, insert the form, set ID = "gofrm", the action is "../dkgo.aspx", the method is "POST"; insert a text box, set ID = "dkgotxt"; insert Click the "Search" button, and the results are shown in Figure 11-1.
(2) Save the template dkblog.dwt.aspx to update all web pages.
(3) Create a new blank ASP.NET VB dynamic page and save it as dkgo.aspx. Add the data set Ztre, its settings are shown in Figure 11-2.
Figure 11-1 Add related form controls
Figure 11-2 Add data set Ztre
(4) Click the "Advanced" button and change the SQL command:
SELECT * FROM ZT ORDER BY ZITIME DESC
to:
SELECT * FROM ZT WHERE ZTNAME LIKE '%"+Request.Form("dkgotxt ")+"%' ORDER BY ZITIME DESC
The result is shown in Figure 11-3.
Figure 11-3 Modify the data set Ztre
(5) Design the dkgo.aspx page, bind relevant dynamic text to the page, and design important areas. The results are shown in Figure 11-4.
Figure 11-3 For
details on the page settings of dkgo.aspx, please refer to the relevant settings of index.aspx.