The database query results are as follows:
To convert it to JSON in the following format, the first attribute is the UNIX timestamp for the date, and the second is the sales
0group by outdate "; $query = Mssql_query ($sql _initbest), while ($row =mssql_fetch_array ($query)) {Array_push ($result [" Data "], $row);} echo Json_encode ($result);? >
Do not know how to turn the date format, the JSON format is not to ask the great God
Reply to discussion (solution)
How is the value of the sales column smaller?
How is the value of the sales column smaller?
It's not changing ... I don't know how to stitch the JSON.
I am now stitching strings but the date format is not and required,
0group by outdate "; $query = Mssql_query ($sql _initbest), $items =array (); echo" {' Data ': "; while ($row =mssql_fetch_array ( $query) {echo "[". Strtotime ($row ["outdate"]). ",". $row ["Sales"]. "],\n";} echo "]}";? >
while ($row =mssql_fetch_array ($query)) { $result ["Data"] [] = Array ( strtotime ($row ["outdate"]). ' $row ["Sales"]);} echo Json_encode ($result);
To be a hard-to-come? It?
$arr = Array (' data ' = = = Array (' 1161043200000,74.29 '), Array (' 1161043200001,74.53 '), Array (' 1161043200002,78.99 '), Array (' 1161043200003,79.95 ')); Echo Json_encode ($arr);
while ($row =mssql_fetch_array ($query)) { $result ["Data"] [] = Array ( strtotime ($row ["outdate"]). ' $row ["Sales"]);} echo Json_encode ($result);
Format is not correct, the timestamp and the sales requirement are numeric types.
It's impossible! Post it and remember to output the results
In JSON format specification, both the key and the value are enclosed in double quotation marks (although numeric types are not allowed in quotation marks)
So you can't literally judge the data type of a number string.
If you want numbers, you can use Floatval to turn them into numbers.
while ($row =mssql_fetch_array ($query)) { $result ["Data"] [] = Array ( floatval (Strtotime ($row ["outdate"]). ' Floatval ($row ["Sales"]);} echo Json_encode ($result);
What's the output of this? $result ["Data"]
Thank you all!
while ($row =mssql_fetch_array ($query)) {$result ["data"] [] = Array ( strtotime ($row ["outdate"]). ' Ceil ($row [' Sales ']);} echo Json_encode ($result);
The result is:
Highcharts use is to remove the double quotation marks from the JSON.