PHP Modules Tutorials - Herong's Tutorial Examples - v5.19, by Herong Yang
mysqli_fetch_array() - Fetch Row from Query Result
This section provides a tutorial example on how to fetch the next row from the query result by calling the mysqli_fetch_array() function.
If you are running a SELECT query, you can fetch the next row from the query result using the mysqli_fetch_array() function:
$row = mysqli_fetch_array($res);
where:
$res - The SELECT query result object
$row - The next row from the result as an array with
indexed by both column positions and headers.
Ther are several other functions related to mysqli_fetch_array():
mysqli_fetch_row($res) - Fetches the next row indexed by positions mysqli_fetch_assoc($res) - Fetches the next row indexed by headers mysqli_num_rows($res) - Returns the number of rows in the result mysqli_free_result($res) - Frees the query result
Here is a PHP script example showing you how to use the mysqli_fetch_row() function:
%lt;?php # mysqli-insert-id.php
If you run the script, you will get the following output:
herong$ php mysqli-fetch-array.php Number of rows: 4 Row 1: 1, 100 Row 2: 2, 200 Row 3: 3, 300 Row 4: 4, 400
Table of Contents
Introduction and Installation of PHP
Managing PHP Environment and Modules on macOS
Managing PHP Environment and Modules on CentOS
DOM Module - Parsing HTML Documents
GD Module - Manipulating Images and Pictures
►MySQLi Module - Accessing MySQL Server
MySQLi Module and Configuration
mysqli-hello.php - Test MySQLi Module
mysqli_connect() - Open MySQL Connection
mysqli_query() - Run SQL Queries
mysqli_affected_rows() - Count Affected Rows
mysqli_insert_id() - ID from AUTO_INCREMENT
►mysqli_fetch_array() - Fetch Row from Query Result
mysqli_fetch_fields() - Fetch Field Information
Escape Escape Characters - \\\\ for \\
Summary of Basic MySQLi Functions
MySQLi Object-Oriented Programming
OpenSSL Module - Cryptography and SSL/TLS Toolkit
PCRE Module - Perl Compatible Regular Expressions
SOAP Module - Creating and Calling Web Services
SOAP Module - Server Functions and Examples