Search Function of PHP Mall


Hello, everyone. Today, I share the search function of a shopping mall, which is based on the previous article.

Search function is simply to achieve fuzzy search in database through SQL statements

  1. Connect to the database to realize paging (refer to the previous article)
  2. Define a variable that receives the value of the incoming search box ($key = $GET [‘key’])
  3. SQL = select * from house_info_copy where 1 = 1 and title like’%’or desc1 like’%’ limit 3,3 // / Define SQL statements to deblur database queries;
$whereStr = "where 1 = 1 ";
        $key= "";

            $key = $_GET['val'];

        $whereStr .= " and title like '%{$key}%' or desc1 like '%{$key}%' limit ".$limitStr.",".$pageSize;
        // Query data in database
        $sql = "select * from house_info_copy ".$whereStr;

The screenshots are as follows
Search Function of PHP Mall

3. Next, get the code of the page number behind the pagination and connect the value of the incoming search.
The screenshots are as follows
Search Function of PHP Mall

* For reference only, if there are any errors, please contact the author.*

Recommended Today

Introduction and overview of NoSQL

1.1 INTRODUCTION1.1.1 1 under the background of Internet era, why do you use nosql1 single machine MySQL In the 1990s, the number of visitors to a website was generally small, and it could be easily handled with a single database. At that time, there were more static web pages and less dynamic interactive websites. Under […]