[英]Print session variable (array) in x axis of Highcharts
I need to print dates I get a sql query. 我需要打印日期,得到一个sql查询。 I keep these dates in an array, and the array put it in a session ($ _SESSION ['dates'] = $ dates). 我将这些日期保存在一个数组中,并将该数组放入会话中($ _SESSION ['dates'] = $ date)。 The problem is that when I do an "echo" of the year, the month and the day, I do not do returns or strange numbers. 问题是,当我执行年,月和日的“回声”时,我没有做任何回报或奇怪的数字。 I tried with "json_encode", but something I'm doing wrong. 我尝试使用“ json_encode”,但是我做错了。 Thank you all. 谢谢你们。
In this "php" I keep the dates in an array and session: 在此“ php”中,我将日期保留在数组和会话中:
<?php
$datayMin = array();
$datayMax = array();
$dataEMF = array();
$dates = array();
$i = 0;
while($row = mssql_fetch_array($consulta)) {
//Suma de EMA + UMA(error máximo admitido + incertidumbre máxima admitida)
$valor = $row[5] + $row[6];
$dataEMF[] = $row ["EMF"];
$datayMin[] = $row ["EMF"] - $row ["UMF"]; //Punt més baix (Error - Incertesa)
$datayMax[] = $row ["EMF"] + $row ["UMF"]; //Punt més alt(Error + Incertesa)
$dates[$i] = $row[2];
$html .= ' <tr>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.$row[0].'</font></td>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.htmlentities($row[1]).'</font></td>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.$row[2].'</font></td>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.$row[3].'</font></td>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.$row[4].'</font></td>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.$valor.'</font></td>
<td bgcolor="#FFFFFF" style="border-radius: 3px;"><font size="1" face="Verdana">'.$row[7].'</font></td>
</tr>';
$i++;
}
echo $dates[0];
$_SESSION["dates"] =$dates; // PUT ARRAY INTO SESSION!
echo var_dump($_SESSION["dates"]);
echo($html);
?>
This script (Highcharts function), print the results (not working properly): example -> [Date.UTC(year, month, day), value] 此脚本(Highcharts函数),打印结果(无法正常工作):示例-> [Date.UTC(年,月,日),值]
series: [{
name: 'EMF',
type: 'line',
zIndex: 10,
data: [[Date.UTC(<?php echo substr(json_encode($_SESSION["dates"]["0"]), -4); ?>, <?php echo substr(json_encode($_SESSION["dates"]["0"]), 3,2); ?>-1, <?php echo substr(json_encode($_SESSION["dates"]["0"]), 0,2); ?>), 0],
[Date.UTC(2013, 10, 10), 0.6 ],
Finally say that the format returned by the query is 2/12/2014. 最后说查询返回的格式为2014年2月12日。 And this is how I want it! 这就是我想要的!
在json_encode中添加此标志,例如:json_encode($ _ SESSION [“ dates”] [“ 0”],JSON_NUMERIC_CHECK)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.