2
to with a doubt that may be easy, but to broken the head, I have a table that is generated through an array, follows code below:
foreach($grupo_arr $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
generates the table below (photo):
as you can see has a column "Group", these groups go from 1 to 5, well, I would like each change in a group, had a row below with the summary of that group, as an average of production values, efficiency etc, but that’s not the problem, the problem is how to include this line with the summary to each group change, some idea, I thank you already!
Context: the user filters by date, what I want to do is that it already comes separately in the query, at the time that the user filters, does not need refresh, the image of the post reflects as it is today, but without the abstract by group
sparse result would be the one of the photo below, done in excel, lines in yellow
I confess that I did not understand, you want this to occur automatically, without the user give refresh on the page?
– Marcelo
@Marcelo thanks for the return, the user filters by date, I want to come already separate in the query, at the time the user filters, no need to refresh, the image of the post reflects as it is today, but without the summary by group
– Denis L. Murara
You can create an if before the group to enter the values
– adventistaam
Ahh... you want to make totals by group, rs
– Marcelo
You create a variable before the start of the loop with the value of the first group, within the loop compare this variable with the current group, if it is different Oce inserts the total, after the loop you insert the last total, because it will not be possible inside the loop, I hope I was understanding.
– Marcelo
@Marcelo understood yes, in the image there are only 2 groups, but there will be 5 groups, you suggest to compile the 5 groups into 5 variables before the loop? I added an image with the expected result too.
– Denis L. Murara
No, the variable receives the new group as soon as it changes to be compared with the next one again, I will put an example in the answer
– Marcelo