Build your Website news automatic Publishing System VII

Source: Internet
Author: User
Tags include key string
Immediately following the section, our news system has been able to complete daily News online additions, delete, and so on, but this is still not enough, some users may need to look up some of the past topic content related news items, and a better than the teaching of the news system, of course, can not help but also to complete this function.
Now for our news system to add (full text/title) of the search function, first we do a search form, see the following HTML code, put the code on the Web page that needs news retrieval. can provide users with the convenience to complete the news search.
"Form method=" POST "action=" http://XXX..com.cn/cgi-win/search/search.asp"》
"P" "Select Name=" select "size=" "1"
Option selected value= "search_1" News Search (title) "/option"
Option value= "search_2" News Search (Full text) "/option"
"/select" "Input type=" text "name=" key "size=" 20 "" input
Type= "Submit" value= "Search"
Name= "Search" "P"
"/form"
On the basis of this form add the ASP program search.asp to process the search. In the table alone we use the key parameter to indicate the string that needs to be matched, and the select parameter specifies whether it is based on Full-text search or title search.
Now go to the Program Processing section and look at our search.asp program.
*search.asp
% @language = "VBScript"%
《%
If Request.Form ("key") = "" Then
Response.Redirect "/"
End If
Select Case Request.Form ("select")
Case "Search_1"
%》
"The!--#include virtual="/cgi-win/search/news/data.inc "
《%
Set rs_1 = Server.CreateObject ("ADODB. Recordset ")
Sql= "SELECT * from Data where InStr (News_title, '" &request.form
("Key") & "0"
sql=sql+ "ORDER by news_id Desc,news_class ASC"
Rs_1.open sql,conn_1,3,2
Case "Search_2"
%》
"The!--#include virtual="/cgi-win/search/news/data.inc "
《%
Set rs_1 = Server.CreateObject ("ADODB. Recordset ")
Sql= "SELECT * from Data where InStr (News_comment, '" &request.form
("Key") & "0"
sql=sql+ "ORDER by news_id Desc,news_class ASC"
Rs_1.open sql,conn_1,3,2
End Select
If Rs_1.bof Then
Response.Redirect "/"
Response.End
End If
Rs_1.movefirst
dispmess= "Table border=0 width=100% cellpadding=0 cellspacing=0
Class=a9 "
Disp= ""
Do as not rs_1.eof
If not rs_1.eof then
disp=disp& "TR" "TD" "a href=http://www.aaaaa.com.cn/news/read.asp"?
News_id= "&rs_1 (" news_id ") &" Target=_blank "" &rs_1 ("News_title")
& "Font size=1" ("&rs_1" ("News_month") & "-" &rs_1 ("News_day") & ")
"/font" "/A" "/td" "/tr" "P" "
Rs_1.movenext
End If
Loop
Dispmess=dispmess&disp

dispmess=dispmess& "The/table"
' Dispmess= ' document.write (' "&dispmess&") "
%》
"%=dispmess%"
By passing in the key argument and select (Full-text or title retrieval parameters), generate a SQL query statement, respectively in the title of the database field or in the contents of the field to find whether there is a key string, such as the words are added as our result Recordset, and finally the news title displayed. The output interface, of course, can meet your personal needs, customized, here does not use pagination to show. You can design it more perfectly on the basis of this press release system, combined with your own needs.
At this point, our personal website Automatic news release system is basically finished.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.