ASP programming: Hold Your own press conference

Source: Internet
Author: User
Tags add date format functions query zip linux
Programming
Update the Daily news content, the webmaster is a very headache. After collecting a lot of news materials, we must make a lot of web pages. Every day big and small international news, domestic news, it news, can really you tired. The most lethal point is that these loosely organised news are not manageable. Cannot query, can not be online dynamic pruning. News stresses timeliness, when you make a good web page and then uploaded to the server, I am afraid that someone else has to first step out of the news report, when it is a thankless task. For our current Internet environment, the realization of online publishing news, dynamic generation of news pages, for news to add search and find functions is essential.

There are two ways to customize the News publishing system: First, the input of the news content automatically generated by the program directly HTML files, such as by date and news ID number to do the name of the HTML file, we often can see from a number of big news sites such treatment. The other is to save the news data directly to the database, when the user read the news, from the database to pull out the data, dynamic generation of the page.

What is the difference between the two treatments? The first kind of display speed and the load on the server is the lightest. For the large flow of the site, speed is life, the site is too slow, who to browse it? The latter method is easy to deal with and easy to maintain. Because only the application database can easily handle the query, so that the reader to guide the corresponding news page. The above method, can be said to be the same, now we mainly introduce the use of the database methods.

First, the processing process

From the processing process, the main is to provide a management news page (can add and delete Daily News, including news pictures, titles, etc.), and then in the call News display page to deal with. Given that the news needs to be plugged into different styles of Web pages, you can't use a fixed-format page to display news feeds, and you should make them a pluggable part of the homepage. Just like the following script statement

<script language= "JavaScript" src= "http//xxx.com.cn/special/linux/lnews/autoup.asp" >
</script>

Finally, there is a detailed content page for reading the news. In general, a program that can complete an online news release consists of a total of four programs: addnew.asp (used to save news data to the database), delete.asp (for handling deleted news), Autoup.asp (used to handle the display of news headlines, which is the part of the homepage), read.asp (the details of dynamically generated news).

The parts of the assistance processing are set_disp.asp (used to handle the number of reports on the homepage, etc.).

Of course, the essential thing is a news database.

Second, add and manage daily news content
  
When a news submission is made, the content of the news is processed by an ASP program called Addnew.asp to classify and save. In order to be clear, each time we submit a piece of news, the following news content Library is reread, so that we can see whether the news is successful in the database or can easily delete the news content.
  
Now let's see how the addnew.asp completes the process.

Source code Download Address: Http://www.popunet.com/2001/zip/39-1.zip

The procedure first determines whether the submitted news meets the criteria. For example, news headlines can not be empty, and line breaks must be converted to the HTML statement "BR", otherwise it can not normally display the format of the news, And here we have a file containing data.inc, its use is mainly used to connect different databases, so the ASP program through the inclusion of this file to specify the data source, then when the change in the use of other databases, only need to change the file, you can easily achieve the switch between different databases, is it very convenient?
  
The contents of the following Data.inc file.
<%
Set conn = Server.CreateObject ("ADODB. Connection ")
DBPath = Server.MapPath ("/") & "/news/data/data.mdb"
Conn. Open "Driver={microsoft Access driver (*.mdb)};d bq=" & DBPath
%>
 
And the one that needs to be noticed Winnt and Windows 98 date-time functions return a different value, Win98 is calculated in 24 hours, while NT Server uses 12 hours, plus "morning" and "afternoon" to indicate, so a little change processing is required.
 
After the program is processed, redirect the delete.asp file to refresh the display in the news database, then we can immediately see whether the results of the execution are successful if each piece of news material is submitted.

The following is the contents of the delete.asp file.

Source code Download Address: Http://www.popunet.com/2001/zip/39-1.zip

Delete.asp is also an ASP file that forms the Webadmin.htm management page, which is responsible for the headline display of the news database so that you know what news is in the library now. You can also use it to delete news records. Another additional ASP program set_diap.asp is used to control the number of displays on the home page for each type of news, which is mainly set using application objects.

<% 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"
%>
  
Complete the above program, our press release system can use the online add, delete and set the display function. Need to add search function, can also be added on this basis. In the next section, we'll analyze how to embed news code into different Web pages to achieve real online news functionality.

Insert the news code into the page
  
The best news release is of course customized for the site itself, which can be consistent with the homepage style, but this way, the news release system and lack of versatility, can not be transplanted to other sites to use. There is a loss, the key is to find a balance point. Combined to consider, the best approach is to separate from the page, so you can not affect the appearance of the Web page, but also to achieve good results. On a Web page that uses news, we can invoke the news code by placing one of these script statements:

<script language= "JavaScript"
src= "Http//xxx.com.cn/special/linux/lnews/autoup.asp" >

Now let's take a look at the autoup.asp code.

Source code Download Address: Http://www.popunet.com/2001/zip/39-1.zip

By customizing this code, you can create a Web page display format that meets your requirements.
  
OK, add, delete, show all finished, the last one, is the details of the news show. When the user clicks on the news headline, he opens the Disp.asp file and uses the Get method to pass the argument over.

Disp.asp's File contents:

Source code Download Address: Http://www.popunet.com/2001/zip/39-1.zip

So far, the press release system has been able to put into use, try, is not very convenient, it is easy to add the daily news content. We can also add the title/Full-text search function to the news publishing system to make it more perfect.



Related Article

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.