I want to count the INSERTs made in a month, for that at INSERT I have a field called date $fecha=date("n/Y");
but I want to count how many INSERT I made on that date, and then show it on a graph with Morris.JS X seria la el mes y año
e y seria la suma de insert de esa fecha
I have the following code
<script>
new Morris.Line({
// ID of the element in which to draw the chart.
element: 'myfirstchart',
data: [
<?php echo $chart_data ?>
],
// x fecha de ingreso.
xkey: 'fecha',
// y contar los datos de ingreso de tal fecha.
ykeys: [''],
labels: ['Ingresados']
});
</script>
SELECT DISTINCT (fecha)
FROM trabajador
WHERE fecha
IN (SELECT fecha
FROM trabajador
GROUP BY fecha
HAVING count( fecha ) >0)
ORDER BY fecha DESC;
<?php
//index.php
include('include/conexion.php');
$query = "SELECT DISTINCT (fecha) FROM trabajador WHERE fecha IN (SELECT fecha FROM trabajador GROUP BY fecha HAVING count( fecha ) >0) ORDER BY fecha DESC;";
$result = mysqli_query($conn, $query);
$chart_data = '';
while($row = mysqli_fetch_array($result))
{
$chart_data .= "{ fecha:'".$row["fecha"]."'}, ";
}
$chart_data = substr($chart_data, 0, -2);
?>
my database
-09/2017, 1
-11/2017, 1
-10/2017, 3