How to build a website using PHP in Linux

Source: Internet
Author: User
For details about how to build a website using PHP in a Linux operating system, and how to build a news system using PHP in a Linux operating system? A complete news system includes not only news interfaces for browsing, but also powerful functions of control and background management. How can we schedule the allocation of sub-functions in these functions? Next we will introduce "> <LINKhref =" http: // www. php1

How can we build a news system? A complete news system includes not only news interfaces for browsing, but also powerful functions of control and background management. How can we schedule the allocation of sub-functions in these functions? The following describes the configuration control of each function. The implementation of the news system is simple, but it is also very complicated.

The news system can be divided into three parts: the administrator logs on to the system, the news management system, and the user browsing system. The entire process is simple:
1. management personnel publish news --> database --> Users browse news

2. locate the problem --> log on to the management system --> edit and modify the news

The above process seems simple, but it is not so simple to implement. this is a system development that is far more complicated than the implementation of the message board, but the basic operation principle is the same as that of the message board. The top priority of the news publishing system lies in the database planning and management system implementation.

What is news now: news classification and information ontology. The two items in the database package letter can be implemented in one data table, but they are not economical. Therefore, we can use two data tables to store the content separately, and one specifically stores the news classification, another ontology is used to store information. How can we call this function to share two tables? Table join is used to solve this problem (this section does not introduce this knowledge. you can refer to the database-related knowledge and obtain the most valuable knowledge from your own efforts, right ?)

The following describes how to implement the management function:

1. first, publishing news

This is a combination of a series of submission forms. here there are two categories: creating news categories and publishing news; creating news categories, and then publishing relevant news in each category, easy! This is not the case. think about how all the information ontology is concentrated in a data table and how to distinguish information classification. The Table Association mentioned above is very important, of course, this method is not required. creating an independent table for each category can solve the problem, but is it cost-effective? What about maintainability and scalability?

The call of news classification and information ontology causes trouble. right, the solution is to use table Association.

2. Editing, modification, and deletion problems

This is the basic application of php + mysql knowledge. it is not difficult to implement these functions. I will not introduce them much here, but note that when you change or delete a category, how can we process the information ontology under this category? Because table Association is used, these functions are processed in a table.

3. handling multiple jobs

But what happens when many people edit a piece of news at the same time? In this case, the database will only store the Last Edited content. this situation will mean that the previous modified users are working hard in vain. to solve this problem with multiple efforts, the primary approach is to take the lead, that is, you have the editing permission first, and then you have only the browsing permission until the editing is complete. This function is like linux permission control, isn't it?

There are several ways to complete this function: 1. Use cookies to control, 2. Add a weight control field to the table. Of course, it is easier to use cookies. the method and process of implementing cookies are as follows:

When an administrator enters the editing process and sets the cookie, the cookie value is determined by the program segment of the editing function. If this parameter is set to null, the cookie value can be edited. if it is not null, the cookie is denied. when you exit the editing process, the cookie is cleared; the multi-job 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 page flip function (introduced on this site), the powerful news system is basically completed, and it seems that a very important function is missing. good news is the search engine. Having a powerful search engine is the wish of every website, and making a powerful search engine is quite complicated and difficult. it involves efficiency, accuracy, speed, and many other aspects.

The search engine described here does not involve such in-depth research, but performs precise queries for specific content. A complex and powerful search engine requires a lot of programs and database skills. let's start with a simple search engine. What is the working status of the search engine? It receives the given keywords, searches within the given range, and returns the search results.
The given keywords may be anywhere in the information content. how does the engine search? The following database statements are used here:



Select * from table where (name like '% ". $ keyword." % ');

Name is the specific location of the search. Generally, the field name is like '% ". $ keyword. "% 'Indicates a pattern match, that is, to find $ keyword in the content. Let's look at an example:

Search for all titles that contain the keyword "good" in the news table:



Select * from news where (title like '% good % ');

This is an exact search. you can find all the good titles in the database. There is also a fuzzy search:



Select * from news where (title like '% good ');

In this way, you can also find out the results.

If news contains fields such as title, message, and user, the search range is too narrow, because only the title is searched, what should I do if I want to search other content and do not want to perform operations that are too complicated?

We noticed that the variable is used to process any variable values in the program. this method works the same way, and the range to be searched can be transmitted as a variable, the following database syntax is available:



Mysql_query ("select * from news where ($ name like '%". $ keyword. "% '));

$ Name stores the value of the transferred field variable, and the variable value is submitted through the select drop-down form of html. How can I limit the search results to a certain time range? If you want to search for information within five days. Remember the database syntax used in cookie introduction?

By the way, the union syntax is as follows:



Mysql_query ("select * from news where ($ name like
'% ". $ Keyword. "% ') And time> date_sub (' $ time', interval 5 day )");
 

$ Time indicates the current search time: $ time = date ('Y-m-d H: I: s'); time indicates the time field of the database storage information. Now replace $ old with 5:



Mysql_query ("select * from news where ($ name like
'% ". $ Keyword. "% ') And time> date_sub (' $ time', interval $ old day )");
 

Similarly, the value of $ old is submitted at different times through the select submission form, which completes this powerful search engine. Some more powerful search engines require the combination of programming skills. readers can expand the experiment by themselves through the above principles.

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.