Tutorials to .com

Tutorials to .com » Asp » Skills » Build your web site news release system of the two auto -

Build your web site news release system of the two auto -

Print View , by: iSee ,Total views: 12 ,Word Count: 2032 ,Date: Tue, 25 Aug 2009 Time: 10:00 AM

(B) add and manage the daily news content when carried out after the submission of news would be handled by a procedure called addnew.asp the asp processing of news content for the classification and preservation, in order to show high definition, each of us to submit 1 news, following the news on the re-read into the content library so that you can see whether the press can be successfully joined both the database, you can also put it to remove the news content.
Now take a look at addnew.asp is how to complete the process to deal with.

"% @ Language =" vbscript "%"
"%
response.buffer = true
Response.Expires = 0

'Save the data
session ( "title") = request.form ( "title")
session ( "comment") = request.form ( "comment")
session ( "pic") = request.form ( "pic")
session ( "class_name") = request.form ( "class_name")
session ( "head") = request.form ( "head")

'To determine the parameters pass over it does meet the requirements
if request.form ( "title ")="" then
response.redirect "delete.asp"
end if

if request.form ( "comment ")="" then
response.redirect "delete.asp"
end if

if request.form ( "class_name ")="" then
response.redirect "delete.asp"
end if


select case request.form ( "class_name")

case "market situation"
class = 1
case "IT News"
class = 2
case "Guangzhou market"
class = 3
case "reservation"
class = 4
case "reservation"
class = 4

end select


'Connect to database
% "
"!--# Include Virtual = "/ news / data / data.inc" - "
"%

Set rs = Server.CreateObject ( "ADODB.Recordset")
sql = "select * from data order by news_id ASC"
rs.open sql, conn, 3,2

'Find Number
if rs.bof then
reco = 0
else
rs.movelast
reco = Clng (rs ( "news_id")) +1
end if

rs.addnew
rs ( "news_id") = reco

if request.form ( "head") = "YES" then
rs ( "news_head") =- 1
end if

rs ( "news_class") = class
rs ( "news_class_name") = request.form ( "class_name")
if request.form ( "pic ")"""" then
rs ( "news_pic") = request.form ( "pic")
rs ( "news_title") = request.form ( "title ")&"( Graphic)"
else
rs ( "news_title") = request.form ( "title")
end if



if request.form ( "head") = "YES" then
rs ( "news_head") =- 1
end if

tmpmess = request.form ( "comment")
tmpmess = replace (tmpmess, chr (10), "
")
tmpmess = replace (tmpmess ,""",""")
tmpmess = replace (tmpmess ,""",""")
tmpmess = replace (tmpmess, "
""
")
rs ( "news_comment") = tmpmess
rs ( "news_year") = year (Date)
rs ( "news_month") = month (Date)
rs ( "news_day") = day (Date)
if Instr (Time, "afternoon") "0 then
tmp = left (right (Time, 8), 2) +12
rs ( "news_time") = tmp & right (Time, 6)
else
rs ( "news_time") = tmp & right (Time, 8)
end if

rs ( "news_delete") = 0
rs.update
rs.close

response.redirect "delete.asp"
% "


First, the submission process to determine whether it complies with the conditions of news, such as news headlines is not empty, and line breaks have to convert the html statement br, or inability to show the format of news, but here using a include file data.inc, its usefulness is mainly used to connect to a different database, asp program by including this file to specify the data source, then when the changes to use a different database, just need to change this file, you can easily implementation to switch between different databases, is not very convenient points?
The following data.inc contents of the file.
"%
Set conn = Server.CreateObject ( "ADODB.Connection")
DBPath = Server.MapPath ("/")&"/ news / data / data.mdb "
conn.Open "driver = (Microsoft access Driver (*. mdb)); dbq =" & DBPath
% "


There is need to look at the NT and windows 98 the date and time values returned by the function is different, win98 calculated based on a 24-hour, while NT Server is used 12 hours, plus "AM" and "afternoon" to indicate, it needs to be a little more of this treatment.

After the procedure, re-oriented delete.asp this asp file, used to refresh the display of information within the database, then each submit a news information, we can see immediately whether the results of the implementation a success.
The following is delete.asp contents of the file.
"% @ Language =" vbscript "%"
"%
response.buffer = true
Response.Expires = 0

% "
"!--# Include Virtual = "/ news / data / data.inc" - "
"%

Set rs = Server.CreateObject ( "ADODB.Recordset")
sql = "select * from data order by news_class ASC, news_id Desc"
'rs.PageSize = 100
rs.open sql, conn, 3,2


% "
"Html"

"Head"
"Meta http-equiv =" Content-Type "content =" text / html; charset = gb2312 ""
"Title" information in the database information stored in "/ title"
"Meta name =" GENERATOR "content =" Microsoft FrontPage 3.0 ""
"Style TYPE =" text / CSS ""
"! --
. lh22px (font-size: 12px; line-height: 22px; font-family: Arial)
a (text-decoration: none)
body (line-height: 18px; font-size: 9pt; font-family: Arial)
td (line-height: 18px; font-size: 9pt; font-family: Arial)
a: hover (color: # FF0000; text-decoration: none)
- "
"/ Style"
"Meta name =" Microsoft Border "content =" none ""
"/ Head"

"Body"

"Form method =" POST "action =" delete.asp ""
"Table border =" 0 "width =" 750 "cellpadding =" 0 ""
"Tr"
"Td width =" 750 "bgcolor =" # EBEBEB "colspan =" 2 "" "div align =" center "" "center" "p" "font
size = "3" "" strong "information in the database information stored in" / strong "" / font "" / td "
"/ Tr"
"%
do while not rs.eof
% "
"Tr align =" center ""
"Td width =" 112 "bgcolor =" # EBEBEB "" whether to delete: "% if rs (" news_delete ") =- 1 then%"
"Input type =" checkbox "name =""%= rs (" news_id ")%""
value = "ON" "
"% Else%"
"Input type =" checkbox "name =""%= rs (" news_id ")%""
value = "OFF" "
"% End if%"
"/ Td"
"Td width =" 638 "bgcolor =" # FAFAFA "align =" left "" "% if rs (" news_class ") = 1 then%"
"Font color = red" market situation "/ font"
"% End if%"
"% If rs (" news_class ") = 2 then%"
"Font color = red" IT News "/ font"
"% End if%"
"% If rs (" news_class ") = 3 then%"
"Font color = red" Guangzhou market, "/ font"
"% End if%"
"% If rs (" news_class ") = 4 then%"
"Font color = red" reservation "/ font"
"% End if%"
"% If rs (" news_class ") = 5 then%"
"Font color = red" reservation "/ font"
"% End if%"
"% = Rs (" news_title ")%""/ td "
"/ Tr"
"%
rs.movenext
loop
% "
"Tr align =" center ""
"Td width =" 100% "colspan =" 2 "bgcolor =" # EBEBEB "" "center" "p" "input
type = "submit" value = "submit" name = "B1" "" input type = "reset"
value = "Clear" name = "B2" "" / td "
"/ Tr"
"/ Table"
"/ Form"
"/ Body"
"/ Html"
"%

if Request.ServerVariables ( "REQUEST_METHOD") = "POST" then

if not rs.bof then
rs.movefirst
end if
do while not rs.eof
n = trim (cstr (rs ( "news_id")))
if request.form (n) = "OFF" then
rs.delete
rs.update
end if
rs.movenext
loop
response.redirect "delete.asp"

rs.close
end if
response.flush
% "
delete.asp is also a composition webadmin.htm management asp page document, which is responsible for the title of news database shows that in order to let you know that libraries use some news. At the same time through it to remove the News-Record, then we use the information in response to out of the home page where the result is dynamic, and news to be online to add and remove. Asp so that an additional procedure outside
set_diap.asp is used to control each category of news on the home page displays the number, which is mainly used to set the application object.

"% @ Language =" vbscript "%"
"%
response.buffer = true
Response.Expires = 0

application ( "disp_1") = request.form ( "disp_1")
application ( "disp_2") = request.form ( "disp_2")
application ( "disp_3") = request.form ( "disp_3")
application ( "disp_4") = request.form ( "disp_4")
application ( "disp_5") = request.form ( "disp_5")


response.redirect "delete.asp"
% "

Completed the above process, our online press release system can add and delete, set display features such as the need to add search function, you can also add on this basis. The next section, we analyze, how; to make the code embedded in a different news page, a real on-line information functions.


ASP skills Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.