PHP MySQL Implementation login and fuzzy query two major functions, MySQL fuzzy query _php tutorial

Source: Internet
Author: User
Tags learn php learn php programming mysql version php session php mysql

PHP MySQL implementation of landing and fuzzy query two major functions, MySQL fuzzy query


The software version used in this article is as follows: PHP version 5.5.12;mysql version 5.6.17;apache 2.4.9 wampserver
First, Phpmysql realization landing
Altogether contains two documents:login.php and logincheck.php;
Form code:


Background processing code:

<?php if (Isset ($_post["Submit"]) && $_post["submit"] = = "Login") {$user = $_post          ["username"];          $PSW = $_post["password"]; if ($user = = "" | |          $PSW = = "") {echo "";              } else {$link = Mysqli_connect (' localhost ', ' sa ', ' 123456 ', ' account ');//LINK database              mysqli_select_db ($link, "account");              Mysqli_query ($link, ' setname utf8 ');              $sql = "Selectuser from Zhanghu where user = ' $_post[username] '";              $result =mysqli_query ($link, $sql) or Die ("Failed". Mysql_error ());    if ($num =mysqli_num_rows ($result)) {$row = Mysqli_fetch_array ($result);                   Store data in an array indexed by echo "Welcome";              ECHO$ROW[0];              } else {echo "";     }}} else {echo ""; }; 

Account Database content:

Second, Phpmysql realize fuzzy query

Querying the database (PHP-only code):

<?php $mysqli =newmysqli ();     $mysqli->connect ("localhost", "sa", "123456");          if (Mysqli_connect_errno ()) {printf ("failllllll:%s\n", Mysqli_connect_error ());     Exit ();       } $mysqli->select_db ("Booklib");        $mysqli->query ("Setnames utf8");  $rsbooks = $mysqli->query ("select * from books where Name like '%$_post[bookname]% '");  $row _rsbooks = $rsbooks->fetch_assoc ();    $totalRows _rsbooks = $rsbooks->num_rows; ?> totel<?php echo $totalRows _rsbooks?>books;
 
 <?php do {?> 
   <?php} while ($row _rsbooks = $rsbooks->fetch_assoc ());?> 
  
Name Isbn Store Do
<?php echo $row _rsbooks[' Name '];?> <?php echo $row _rsbooks[' ISBN '];?> <?php echo $row _rsbooks[' Store '];?> Rent
<?php $rsbooks->close (); $mysqli->close ();? >

The contents of the database table are as follows:

Inquire:

Results:

The above is the whole content of this article, I hope that you learn PHP programming help.

Articles you may be interested in:

    • Two steps to teach you how to open the MySQL database remote login account
    • Implementation method of MySQL single-table multi-keyword fuzzy query
    • Php+mysql Member System login is the authority to determine the implementation of code
    • A simple web password to login PHP code
    • MySQL Add new user Unable to log in workaround
    • MYSQL like fuzzy query wildcard use detailed introduction
    • PHP after landing to jump to the pre-landing page implementation ideas and code
    • PHP Session Exit Login Problem
    • Four ways to use fuzzy queries in MySQL
    • thinkphp implementing a like Fuzzy query instance

http://www.bkjia.com/PHPjc/1099081.html www.bkjia.com true http://www.bkjia.com/PHPjc/1099081.html techarticle php MySQL implementation of landing and fuzzy query two major functions, MySQL fuzzy query This article uses the following software version: PHP version 5.5.12;mysql version 5.6.17;apache 2.4.9 wampserver a 、...

  • Related Article

    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.