Search Function of PHP Mall

Time:2019-10-1

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= "";
        if(isset($_GET['val='])){

            $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

Query SAP multiple database table sizes

Query SAP multiple database table sizes https://www.cnblogs.com/ken-yu/p/12973009.html Item code db02 Here are two approaches, In the first graphical interface, the results of the query data table are displayed in MB, and only one table can be queried at a time. SPACE—Segments—Detailed Analysis—Detailed Analysis  In the pop-up window segment / object, enter the name of the […]