How to set up a news system? A complete news system not only includes a news interface for browsing, it also includes powerful functions for controlling many functions and background management. So how are the sub-functions within these functions scheduled and allocated? Let’s introduce the deployment control of each function. The implementation of the news system is simple, but it can also be said to be very complex.
The news system can be divided into three parts: administrator login system, news management system, and user browsing system. The whole process is simple:
1. Managers publish news--> database--> users browse news
2. Found problems--> log in to the management system--> edit and modify News
The above process seems simple, but the implementation is not that simple. This is a system development, which is far more complicated than the implementation of the message board, but the basic operating principle is the same as the message board. The top priority in the news release system lies in the planning of the database and the implementation of the management system.
What is the content of news now: news classification, information ontology. It is possible to include these two contents in one data table in the database, but it is not economical. Therefore, we can use two data tables to store the contents respectively, one specifically for storing the classification of news, and the other for storing the ontology of the information. . How to call and realize the sharing of the content of dual tables? Use table association to realize this problem (this knowledge is not introduced here. Readers can refer to the knowledge content related to the database by themselves. The knowledge gained through one's own efforts is the most valuable, isn't it? ?)
The following is the implementation of the management function:
1. The first is the release of news
This is composed of a series of submission forms, and here It is divided into two categories: creating news categories and publishing news. After creating news categories, then publish related news in each category. It is very simple! It is not like this. Think about all the information ontology being concentrated in one data table. , how to distinguish the classification of information, the table association mentioned above is very important here. Of course, this method can not be used. Creating an independent table for each classification can also solve the problem, but is this cost-effective? Maintenance and How is the scalability?
The related calls of news classification and information ontology have caused trouble. By the way, the solution is to make use of table associations.
2. Issues of editing, modification, and deletion
This is php(as the current mainstream development language)+MySQL(the best combination with PHP Best combination) It is not difficult to implement these functions based on the basic application of knowledge. I will not introduce too much here, but what you need to pay attention to is when changing or deleting a category, how to deal with the information ontology under this category? Because of the use of Table association handles these functions as if they were handled within a table.
3. Multitasking
But what happens when many people edit a news item at the same time? The situation is that the database will only store the last edited content. This situation will mean The hard work of the previous modification people was in vain. Multi-function processing is the solution to this problem. The method adopted is preconceived, that is, those who enter the editor first have editing permissions, and those who enter later only have browsing permissions until the editing is completed. This function is very similar to the permission control of Linux, isn't it?
There are several methods to complete this function: 1. Use cookies to control,2. Add permission control fields to the table. Of course, it is simpler to use cookies. The method and process of cookie implementation are as follows:
When an administrator enters the editor and sets the cookie, the program segment of the editing function determines the cookie value. If it is empty, editing is allowed, if it is not empty, editing is allowed. then refuse to edit, clear the cookie when exiting editing, and so on; the multitasking function is an effective function, which can at least reduce the waste of time and manpower.
The implementation of the news browsing function is very simple. With the addition of the page turning function (already introduced on this site), the powerful news system is basically completed. It seems that a very important function is missing, which is the search engine. It is the wish of every website to have a powerful search engine, and the production of a powerful search engine is quite complicated and difficult. It involves many aspects such as efficiency, accuracy and speed.
The search engine introduced here will not involve such in-depth research, but only conduct precise queries for specific content. A complex and powerful search engine requires a lot of programming and database skills. Let’s start with a simple search engine. How does the search engine work? It receives the given keywords, searches within the given range, and then returns the search results.
The given keyword may be anywhere in the information content. How does the engine search? The following database statement is used here:
select * from table where (name like %".$keyword."%);
name is the specific location to search, usually the field name, like %".$keyword."% is pattern matching, that is, in the content Check for $keyword. Take an example: