As we all know,
If the function executes successfully, it gets a line of information (which is obtained by executing the mysql_query () function) and returns the row information, and if it fails, no row is returned.
PHP mysql_fetch_array () function syntax
Mysql_fetch_array (Data,array_type)
The data is the necessary parameter, specifying the need to use the pointer to the pointer. The data pointer is returned by requesting the mysql_query () function.
Array_type is an optional parameter. Specifies the type of array returned. The optional parameters are as follows:
* mysql_assoc– associative array [associative array]
*mysql_num– numeric array [Numeric array]
* mysql_both– default value. Contains associative array [associative array] and numeric array [Numeric array]
PHP mysql_fetch_array () function hints and note points
Note: When the specified data is fetched, the function will point to the next record, and if you continue to request the Mysql_fetch_array () function then the next record will be returned.
Tip: The field names returned by the mysql_fetch_array () function do not differentiate between letter case.
PHP mysql_fetch_array () function case
- < ? PHP
- $ Con = mysql_connect ("localhost",
"Peter", "abc123");
- if (! $con)
- {
- Die (' Could not connect: '.
Mysql_error ());
- }
- $ db_selected = mysql_select_db
("test_db", $con);
- $ SQL = "SELECT * FROM person
WHERE lastname= ' refsnes ';
- $ result = mysql_query ($sql, $con);
- Print_r (Mysql_fetch_array ($result));
- Mysql_close ($con);
- ?>
The code above will output the following result:
- Array
- (
- [0] => refsnes
- [LastName] = > Refsnes
- [1] => Kai Jim
- [FirstName] = > Kai Jim
- [2] => taugata 2
- [Address] = > Taugata 2
- [3] =>
- [age] = > a
- )
These are the specific uses of the PHP mysql_fetch_array () function.
http://www.bkjia.com/PHPjc/446052.html www.bkjia.com true http://www.bkjia.com/PHPjc/446052.html techarticle as we all know, if the function executes successfully, it will fetch a line of information (the line is obtained by executing the mysql_query () function) and return the line information, and if it fails, it will not return any ...