Can php load the values of a column in MYSQL into a single-dimensional array? Solution

Source: Internet
Author: User
Can php load the values of a column in MYSQL into a single-dimensional array? For example, can the table name & nbsp; field & nbsp; | ------------ | idclassgrade1aT2bW3c php load the values of a column in MYSQL into a single-dimension array?
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 ();

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.