For how to convert echarts chart data and output data in a fixed format. ECharts has the following two types of data:
Data: ['direct access', 'email marketing ', 'alliance ads', 'Video ads', 'search engine']
Data :[
{Value: 335, name: 'direct access '},
{Value: 310, name: 'directmail '},
{Value: 234, name: 'Alliance ads '},
{Value: 135, name: 'Video ads '},
{Value: 1548, name: 'searchengine '}
]
After I read the corresponding data from the database, how can I convert it to the above two formats ??
Please kindly advise.
Reply to discussion (solution)
I don't understand what you want to express. can I post the data table you want to retrieve?
$ Rs = mysql_query ("select value corresponds to the field name as value, and name corresponds to the field name as name from table ");
While ($ r = mysql_fetch_assoc ($ rs )){
$ D1 [] = $ r [['name'];
$ D2 [] = $ r;
}
$ D1 and $ d2 are the two arrays you want. json_encode is required when returned to echarts.