Home  >  Article  >  Backend Development  >  An example of application of php mysqli extension library

An example of application of php mysqli extension library

WBOY
WBOYOriginal
2016-07-25 09:11:44767browse

Example of php mysqli extension library:

  1. #Connect to database
  2. $link=mysqli_connect("localhost","root","root");
  3. #Select database
  4. $link-> ;select_db("rorely") or die("could not find database");
  5. #Query the database
  6. $result=$link->query("select * from test");
  7. #Output the contents of each record in the database table
  8. while($row=mysqli_fetch_object($result)){
  9. echo $row->id." ".$row->name." ".$row->age." ".$row-> sex." ".$row->address."
    ";
  10. }
  11. #Close the database
  12. mysqli_close($link);
  13. ?>
Copy code

Result: 1 Jane 26 female wenming cun 123# 3 Tome 21 male wenming cun 32# 4 Lily 25 female wenming cun 2# 5 Lucy 25 female wenming cun 2# 6 Jim 22 male wenmin cun 45# 7 Jim 22 male wenmin cun 45#

Articles you may be interested in: How to add extension library to php under Linux Two methods to add CURL extension library to PHP Two examples of preprocessing operations in the php mysqli extension library Example of php mysqli extension library operating mysql



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn