Home > Database > Mysql Tutorial > Usage of mysqli_query()

Usage of mysqli_query()

angryTom
Release: 2020-02-07 16:55:16
Original
11710 people have browsed it

Usage of mysqli_query()

Usage of mysqli_query()

The mysqli_query() function executes a query against the database.

Syntax

mysqli_query(connection,query,resultmode);
Copy after login

Parameter Description

Parameter Description
connectionRequired. Specifies the MySQL connection to use.
queryRequired, specifies the query string.
resultmode##Optional. a constant. Can be any of the following values:

    MYSQLI_USE_RESULT (use this if you need to retrieve large amounts of data)
  • MYSQLI_STORE_RESULT (default)
Usage example:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:RUNOOB 
$con=mysqli_connect("localhost","root","123456","RUNOOB"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "连接 MySQL 失败: " . mysqli_connect_error(); 
} 
 
// 执行查询
mysqli_query($con,"SELECT * FROM websites");
mysqli_query($con,"INSERT INTO websites (name, url, alexa, country)
VALUES (&#39;百度&#39;,&#39;https://www.baidu.com/&#39;,&#39;4&#39;,&#39;CN&#39;)");
 
mysqli_close($con);
?>
Copy after login
(Free learning video tutorial recommendation:

mysql video tutorial)

The above is the detailed content of Usage of mysqli_query(). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template