Differences between php functions mysql_fetch_row, assoc, array, and object. Differences between php functions mysql_fetch_row, assoc, array, and object 1. mysql_fetch_row is used to retrieve a row from the result set as Enumeration data, differences between the php function mysql_fetch_row, assoc, array, and object associated with the specified result identifier
1. mysql_fetch_row
This function extracts a row from the result set as Enumeration data, and obtains a row of data from the result set associated with the specified result ID and returns the data as an array. Each result column is stored in an array unit, and the offset starts from 0.
Note: Here the offset starts from 0. that is to say, the field name cannot be used for the value, but the index can only be used for the value. For example:
While ($ row = mysql_fetch_row ($ res )){
Echo $ row ['CID']. '>>>'. $ row [1].'
';
}
$ Row ['CID'] cannot be obtained here, and $ row [1] can be obtained.
II. mysql_fetch_assoc
Retrieve a row from the result set as an associated array. that is to say, this function cannot be indexed as mysql_fetch_row, and can only be retrieved using field names. For example:
While ($ row = mysql_fetch_assoc ($ res )){
Echo $ row ['CID']. '>>>'. $ row [1].'
';
}
Here, $ row [1] cannot obtain the value. $ row ['CID'] can obtain the value.
III. mysql_fetch_array
Obtain a row from the result set as an associated array or number array, or both. in addition to storing data in the array as a digital index, you can also store the data as an associated index, use the field name as the key name.
That is to say, the result obtained by him is like an array. he can use keys or indexes to take values. For example:
While ($ row = mysql_fetch_array ($ res )){
Echo $ row ['CID']. '>>>'. $ row [1].'
';
}
Here, $ row ['CID'] and $ row [1] can get corresponding values.
The functions of mysql_fetch_row and mysql_fetch_assoc add up to mysql_fetch_array.
IV. mysql_fetch_object
As the name suggests, get a row from the result set as an object and use the field name as an attribute. So only in this way can we get the value:
While ($ row = mysql_fetch_object ($ res )){
Echo $ row-> cid. '>>>'. $ row-> title ."
";
}
Distinct 1. the mysql_fetch_row function extracts a row from the result set as Enumeration Data and associates the row with the specified result ID...