douchengchen7959 2014-11-21 14:46
浏览 45
已采纳

在Highcharts的x轴上打印会话变量(数组)

I need to print dates I get a sql query. I keep these dates in an array, and the array put it in a session ($ _SESSION ['dates'] = $ dates). 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. Thank you all.

In this "php" I keep the dates in an array and session:

<?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]

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. And this is how I want it!

  • 写回答

1条回答 默认 最新

  • douganggu4392 2014-12-01 09:39
    关注

    In the json_encode add this flag, example: json_encode($_SESSION["dates"]["0"], JSON_NUMERIC_CHECK)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择