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!