Can php load the values of a column in MYSQL into a single-dimensional array? For example, the table name & nbsp; field & nbsp; |---| can I load the values of a column in MYSQL into a single-dimension array in idclassgrade1aT2bW3c php?
For example, table name
Field
|
――――――――――――
|
Id class grade
1 a T
2 B W
3 c Z
For example, to load the field class column into a single-dimension array!
By default, mysql_fetch_array loads rows into an array. I want to load a column into an array.
------ Solution --------------------
Mysql returns a two-dimensional array, which you can encapsulate.
------ Solution --------------------
The mysql function Group does not provide this function and needs to be programmed.
PDO provides this function
------ Solution --------------------
You read the value of the column and put it in a single dimension group in the program for use elsewhere.
------ Solution --------------------
So when you query, there is only one field that is not long enough?
PHP code
$ SQL = "SELECT class FROM name"; $ result = mysql_query ($ SQL, $ this-> mysql); while ($ arr = mysql_fetch_array ($ result )) {print_r ($ arr);} mysql_close ();