Last active
February 2, 2017 15:36
-
-
Save andergmartins/3d571ad67c21449b9bad66515cf2b297 to your computer and use it in GitHub Desktop.
Stackoverflow answer - http://stackoverflow.com/questions/41969347/array-to-string-conversion/41969600#41969600
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include dirname(__FILE__) . '/../Database/dbcon.php'; | |
header('Content-Type: text/html; charset=utf-8'); | |
$inicio = $_REQUEST['inicio']; | |
$fin = $_REQUEST['final']; | |
$sql = "SELECT SUM(gastos.Cantidad) 'Cantidad', YEAR(gastos.Fecha) 'anio' | |
FROM ciclo | |
INNER JOIN gastos ON ciclo.Identificador = gastos.year_id | |
WHERE ciclo.Ciclo BETWEEN $inicio AND $fin GROUP BY anio"; | |
$resultado = $conn->query($sql) or die('fecha_fin'); | |
$aux = array(); | |
while ($fila = mysqli_fetch_assoc($resultado)) { | |
$aux[] = (object)array( | |
'year' => $fila['anio'], | |
'value' => $fila['Cantidad'] | |
); | |
} | |
echo " | |
<script> | |
new Morris.Line({ | |
element: 'graph_line', | |
xkey: 'year', | |
ykeys: ['value'], | |
labels: ['Value'], | |
hideHover: 'auto', | |
lineColors: ['#26B99A', '#34495E', '#ACADAC', '#3498DB'], | |
data: " . json_encode($aux) . " | |
}); | |
</script>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment