Recently, I was working on a project for PHP-database interaction. I was eager to seek success. After imitating the example below, I started my work. I mistakenly wrote mysql_fetch_array into mysql_fetch_row, it is found that the returned array is in the form of Index => value, but the field name => value is clearly remembered.
1. The function prototype of mysql_fetch_array is
ArrayMysql_fetch_array(Resource$ Result[, Int$ Result_type= Mysql_both])
Returns an array that corresponds to the fetched row and moves the Internal Data Pointer ahead.
The type of returned array depends on howResult_typeIs defined. By usingMysql_both(Default), you'll get an array with both associative and number indices. UsingMysql_assoc, You only get associative indices (as mysql_fetch_assoc () works), usingMysql_num, You only get number indices (as mysql_fetch_row () works ).
2. this makes it clear that if different parameters are set, mysql_fetch_array () can implement the functions of mysql_fetch_row () and mysql_fetch_assoc (). The last two functions only accept the first parameter, the returned values are associative => value, Index => value arrays.
3. What is mysql_both? I tested it.
SQL: Select firstname, lastname from table where id = "c01 ";
$ Array = mysql_fetch_array ($ result, mysql_both );
$ Array [0] is the same as $ array ['firstname ']