0
I am pulling values BD for a table with the results of the query, this search is by date, is working perfectly if I search for a single day, but I would like when to search for two or more days (ex 07/06/2018 to 08/06/2018), it brings the values grouped (compiled) the days of the query, today it brings the values skipping the lines and not grouping them;
code:
The sql:
$sql = "SELECT * FROM reporte_producao WHERE data_reporte BETWEEN '$data_ida' AND '$data_volta' AND turno = '$turno' AND grupo = '$v' ORDER BY id ASC";
to generate the table:
foreach($num_array as $k => $v){
?>
<tr>
<td><?php echo $num_array[$k]; ?></td>
<td><?php echo $maq_array[$k]; ?></td>
<td><?php echo $grupo_arr[$k]; ?></td>
<td><?php echo $producao_array[$k]; ?></td>
<td><?php echo (($producao_array[$k]) * 2); ?></td>
<td><?php echo $segunda_array[$k]; ?></td>
<td><?php echo $terceira_array[$k]; ?></td>
<td><?php echo $producao_r_array[$k]; ?></td>
<td><?php echo (($producao_r_array[$k])*2); ?></td>
<td><?php echo $eficiencia_array[$k]."%"; ?></td>
</tr>
<?php } //fecha foreach
the most effective way to do this would be below? any suggestions?
$producao += $data['producao'];
Thanks for the feedback @Diego Souza, but could you explain what this line does? I know that GROUP BY groups, but what exactly this code is for?
– Denis L. Murara
It takes your date, transforms it into dd/mm/YYYY format to group. This is necessary because of the time your field probably has and is different. There would be no grouping.
– Diego Souza
nothing appears in the query;
– Denis L. Murara