1.mysql_fetch_row, this function takes a row from the result set as the enumeration data, obtains a row of data from the result set associated with the specified result identity, and returns it as an array. Each result column is stored in an array of cells, with an offset starting at 0. Note that this is offset from 0, that is, you cannot use the field name to take the value, you can only use the index to take the value, so the following code does not take the value:
while ($row = Mysql_fetch_row ($res)) {echo $row [' CID ']. ':: '. $row [1]. ";} There is no value for $row[' CID ' here.
2.mysql_fetch_array, a row is taken from the result set as an associative array, or as a numeric array, or both, in addition to storing the data in a numeric index in an array, you can also store the data as an associated index, using the field name as the key name. That means he gets the results like an array, you can use a key or an index to take a value, so
while ($row = Mysql_fetch_array ($res)) {echo $row [' CID ']. ':: '. $row [1]. ";} Here $row[' CID '], $row [1] can get the corresponding value.
3.mysql_fetch_object, as the name implies, takes a row from the result set as an object, and the field name as a property. So it's the only way to get the value.
while ($row = Mysql_fetch_object ($res)) {echo $row->cid. ':: '. $row->title. ";}
4.MYSQL_FETCH_ASSOC, take a row from the result set as an associative array, that is, this function can not be used as mysql_fetch_row as the index to take the value, only with the field name to fetch, so
while ($row = Mysql_fetch_assoc ($res)) {echo $row [' CID ']. ':: '. $row [1]. ";} $row [1] This is not a value.
MYSQL_FETCH_ROW,MYSQL_FETCH_ARRAY,MYSQL_FETCH_OBJECT,MYSQL_FETCH_ASSOC differences