How can I output the query results in an array.

Source: Internet
Author: User
How can I output the query results in an array .... the following are the results I want to achieve... $ graph-& gt; xaxis-& gt; SetTickLabels (array ('runan mansion ', 'baihua mansion', 'jinmeng mansion ', 'hengfeng mansion', 'huayi mansion ', 'Blue Whale Tower ', 'GG', 'DD', 'FF ', 'hh', 'KK ', 'FF', 'rr ','t how to output the query results in the form of arrays ....
The following are the results I want to achieve...
$ Graph-> xaxis-> SetTickLabels (array ('runan mansion ', 'baihua mansion', 'Golden dream mansion ', 'hengfeng mansion', 'huayi mansion ', 'Blue Whale mansion ', 'GG ', 'DD', 'ff', 'hh', 'KK ', 'ff', 'rr', 'TT ',));


I want to use
$query_1 = "select * from tbl_area";
$sql_1 = mysql_query($query_1);
$row_1 = mysql_fetch_array($sql_1);

In this way, the query results are as follows: 'runan mansion ', 'baihua mansion', 'jinmeng mansion ', 'hengfeng mansion', 'huayi mansion ', 'Blue Whale mansion', 'GG ', 'DD', 'ff', 'hh ', 'KK', 'FF ', 'rr', and 'TT'. how can this problem be achieved when printed, I tried
while ($row = mysql_fetch_array($sql)){echo "'".$row[areaname]."'".",";}
Loop out, but the result is an error when it is embedded .... share To: xaxis-> SetTickLabels (array ('runan mansion ', 'baihua mansion', 'Golden dream mansion ', 'hengfeng mansion', 'huayi mansion ', 'Blue Whale... 'data-pics = ''>
------ Solution --------------------
While ($ row = mysql_fetch_array ($ SQL )){
$ Tmp [] = $ row [areaname];
}
$ Graph-> xaxis-> SetTickLabels ($ tmp );
------ Solution --------------------
Iconv can only be used for strings and is not applicable to arrays.
$ Tmp [] = iconv ("GB2312", "UTF-8", $ row_1 [areaname]);
------ Solution --------------------
Run
Mysql_query ('set names utf8 ');

In this way, the result of your query is UTF-8, and you do not need to transcode it yourself. mysql will do it for you.
------ Solution --------------------
Garbled. Use Notepad to open and save it as code to see if it is UTF-8.

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.