


Building a website: Implementation of search engine_PHP tutorial
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 It will not involve such in-depth research, just 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, then searches within the given range, and then returns the search results.
The given keywords may be in the information How does the engine search for any location in the content? The following database statement is used here:
select * from table where (name like '%".$keyword."%');
name is the specific location to search for, usually the field name, like '%".$keyword."%' is pattern matching, which is to find whether there is $keyword in the content. Let's look at an example:
Search for the content in the data table news All titles with the keyword good:
select * from news where (title like '%good%');
This is a precise search, which can find all titles with good in the database, and there is also a kind of ambiguity Search:
select * from news where (title like '%good');
You can also find the results in this way.
Assume that news contains title (title), message (content), user (user) For fields such as etc., the above search range is too narrow, because only the title is searched. What should we do if we want to search for other contents without making the operation too complicated?
We notice any changed values in the program Variables are used for processing. This method also works here. You can transfer the range you want to search as a variable, so you have the following database syntax:
mysql_query("select * from news where ($ name like '%".$keyword."%'));
$name stores the value of the field variable transmitted, and this variable value is completed through the html select drop-down submission form.
What if you want to limit the search results to a certain time range? For example, if you want to find information within 5 days. Do you still remember the database syntax used in the introduction to cookies?
That’s right , the syntax of this union is as follows:
mysql_query("select * from news where ($name like
'%".$keyword."%') and time>date_sub('$time',interval 5 day) ");
Where $time is the current time of the search: $time=date('Y-m-d H:i:s'); time is the field in which the database stores information time.
Now replace 5 with $old:
mysql_query("select * from news where ($name like
'%".$keyword."%') and time>date_sub('$time',interval $old day)");
Similarly, the value of $old is submitted for different limited times through the select submission form, thus completing this quite powerful search engine.
Some more powerful search engines require the cooperation of programming skills. Readers can use the above Principle self-expansion test.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to implement dual WeChat login on Huawei mobile phones? With the rise of social media, WeChat has become one of the indispensable communication tools in people's daily lives. However, many people may encounter a problem: logging into multiple WeChat accounts at the same time on the same mobile phone. For Huawei mobile phone users, it is not difficult to achieve dual WeChat login. This article will introduce how to achieve dual WeChat login on Huawei mobile phones. First of all, the EMUI system that comes with Huawei mobile phones provides a very convenient function - dual application opening. Through the application dual opening function, users can simultaneously

The programming language PHP is a powerful tool for web development, capable of supporting a variety of different programming logics and algorithms. Among them, implementing the Fibonacci sequence is a common and classic programming problem. In this article, we will introduce how to use the PHP programming language to implement the Fibonacci sequence, and attach specific code examples. The Fibonacci sequence is a mathematical sequence defined as follows: the first and second elements of the sequence are 1, and starting from the third element, the value of each element is equal to the sum of the previous two elements. The first few elements of the sequence

How to implement the WeChat clone function on Huawei mobile phones With the popularity of social software and people's increasing emphasis on privacy and security, the WeChat clone function has gradually become the focus of people's attention. The WeChat clone function can help users log in to multiple WeChat accounts on the same mobile phone at the same time, making it easier to manage and use. It is not difficult to implement the WeChat clone function on Huawei mobile phones. You only need to follow the following steps. Step 1: Make sure that the mobile phone system version and WeChat version meet the requirements. First, make sure that your Huawei mobile phone system version has been updated to the latest version, as well as the WeChat App.

1. Start PPT, create a new blank document, select all text boxes and delete them. 2. Execute the Insert-Shape command, drag a rectangle in the document, and fill the shape with black. 3. Drag the rectangle to elongate it, execute the Insert-Shape command, drag out the small square, and set the fill color to white. 4. Copy and paste the small squares one by one so that the top and bottom are evenly distributed on both sides of the film. After selecting them all with ctrl+a, right-click and select Group. 5. Execute the Insert-Picture command, find the picture to be inserted in the pop-up dialog box, click to open, and adjust the size and position of the picture. 6. Repeat step 5 to insert and set the remaining pictures in order to form a film picture. 7. Select the film, execute animation-add animation command

In today's software development field, Golang (Go language), as an efficient, concise and highly concurrency programming language, is increasingly favored by developers. Its rich standard library and efficient concurrency features make it a high-profile choice in the field of game development. This article will explore how to use Golang for game development and demonstrate its powerful possibilities through specific code examples. 1. Golang’s advantages in game development. As a statically typed language, Golang is used in building large-scale game systems.

PHP Game Requirements Implementation Guide With the popularity and development of the Internet, the web game market is becoming more and more popular. Many developers hope to use the PHP language to develop their own web games, and implementing game requirements is a key step. This article will introduce how to use PHP language to implement common game requirements and provide specific code examples. 1. Create game characters In web games, game characters are a very important element. We need to define the attributes of the game character, such as name, level, experience value, etc., and provide methods to operate these

How to change the search engine in Google Chrome? Google Chrome is a very popular browser among users. It not only has simple and easy-to-use services, practical tools and other auxiliary functions, but also can meet the different needs of different users. Search engines generally default to Google. If we want to How should I set it up to replace it? Let me share the method below. Replacement method 1. Click to open Google Chrome. 2. Click the three-dot icon to open the menu interface. 3. Click the Settings option to enter the browser’s settings interface. 4. Find the search engine module in the settings interface. 5. Click the Manage Search Engine button. 6. You can see an add button. Click this add button to add a search engine.

When making PPT, using some animation effects will make it more lively and cute than without using animation effects. With the addition of animation effects, people may like to watch this PPT, so we must learn how to create animation effects for PPT. Next, I will introduce in detail how to add animation effects to PPT. Please continue reading and study these steps carefully. I believe they will be helpful to you! First, open the PPT we made ourselves. You will notice that this PPT currently does not have any animation effects (as shown by the red arrow in the picture below). 2. Then, we need to add animation effects to the picture. We first select the picture, and then click the [Animation] button on the menu bar (as shown in the red circle in the figure below). 3. Next, we click inside the animation
