What is the difference between mysql_fetch_row () and mysql_fetch_array? What should I do?
Source: Internet
Author: User
What is the difference between mysql_fetch_row () and mysql_fetch_array? What is the difference between mysql_fetch_row () and mysql_fetch_array ?, To read this reply, log on to or register CSDN !, To read this reply, log on to or register CSDN! What is the difference between mysql_fetch_row () and mysql_fetch_array?
What is the difference between mysql_fetch_row () and mysql_fetch_array?
------ Solution --------------------
The two functions return an array. The difference is that the array returned by the first function only contains values. we can only $ row [0], $ row [1], in this way, the data is read by the array subscript, while the array returned by MySQL_fetch_array () contains both the first and key-value pairs. we can read the data in this way, (assume that the database field is username, passwd ):
$ Row ['username'], $ row ['passwd']
------ Solution --------------------
Mysql_fetch_row is a one-row array from the result set, which is used as an enumeration
Mysql_fetch_array is used to retrieve an array from the result set as an associated array or a number array.
Eg:
$ SQL = "select abc, def from ";
$ Res = mysql_query ($ SQL );
So:
$ Row = mysql_fetch_row ($ res );
$ Row: $ row [0] and $ row [1]
So:
$ Row = mysql_fetch_array ($ res );
$ Row results are 4: $ row [0], $ row [1], $ row ["abc"], and $ row ["def"]
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service