Home >Backend Development >PHP Tutorial >Enough to build a website: News release system_PHP tutorial
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 to schedule and allocate the sub-functions within these functions? What? Let’s introduce the deployment and control of each function. The implementation of the news system is simple, but it can also be said to be very complicated.
The news system can be divided into three parts: administrator login system and news management system , users browse the system. The whole process is simple:
1. Managers publish news-->database-->Users browse news
2. Discover problems-->Log in to the management system--> Editing and modifying 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. In the news release system The top priority lies in the planning of the database and the implementation of the management system.
What content does the news contain now: news classification, information ontology.
In the database, these two contents are included in a data table. It can be realized, but it is not economical, so we can use two data tables to store the content separately, one specifically to store the classification of news, and the other to store the ontology of the information. How to call and realize the sharing of the content of the two 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 management function. Implementation:
1. First is the release of news
This is composed of a series of submission forms, and it is divided into two categories, creating news categories and publishing news; after creating news categories, then in each category It's very simple to publish relevant news! It's 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, it is also Instead of this method, creating a separate table for each category can solve the problem, but is this cost-effective? How about maintainability and scalability?
The related calls of news categories and information ontology have caused trouble. By the way, the solution is to make full use of table associations.
2. Issues of editing, modification, and deletion
This is the basic application of php+mysql knowledge. It is not difficult to implement these functions. I will not introduce too much here. Just note that when changing or deleting a category, how to process the information ontology under that category? Due to the use of table associations, processing these functions is as if they are processed in one table.
3. Multitasking
But what happens when many people edit a piece of news at the same time? The situation is that the database will only store the last edited content. If this happens, it will mean that the hard work of the previous editors has been in vain. Multi-function processing is to solve this problem. Yes, 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?
This function is available after completing it. Several methods: 1. Use cookies to control, 2. Add rights control fields in the table. Of course, it is easier to use cookies. The method and process of cookie implementation are as follows:
When an administrator enters the editor, set 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 rejected. When exiting the editing, the cookie will be cleared, and so on; the multitasking function is an effective function, which can at least reduce time and manpower.
The implementation of the news browsing function is very simple. With 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. This The function will be introduced in detail later.