Skip to content

Instantly share code, notes, and snippets.

@andergmartins
Last active February 2, 2017 15:36
Show Gist options
  • Save andergmartins/3d571ad67c21449b9bad66515cf2b297 to your computer and use it in GitHub Desktop.
Save andergmartins/3d571ad67c21449b9bad66515cf2b297 to your computer and use it in GitHub Desktop.
<?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