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;
Name |
Isbn |
Store |
Do |
<?php do {?>
<?php echo $row _rsbooks[' Name '];?> |
<?php echo $row _rsbooks[' ISBN '];?> |
<?php echo $row _rsbooks[' Store '];?> |
Rent |
<?php} while ($row _rsbooks = $rsbooks->fetch_assoc ());?>
<?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 、...