0
Staff I plan to display a report separating the results into date groups as example below
| REF. | NOME | DEBITO |
=====================================
| X741852 | MARIA | 2.500 |
| B890656 | EDUARDA | 500 |
|
| Data: 2015-02-05
-------------------------------------
| CK54604 | JOAO | 42.050 |
|
| Data: 2015-02-18
-------------------------------------
| FE55852 | CHARLES | 28.500 |
| X741852 | VIVIANE | 74.2500 |
|
| Data: 2014-06-09
-------------------------------------
The data comes from a query in DB
$sql = $this->db->query($query) or die (sprintf("Falha: %s", $this->db->error()));
if ($sql->num_rows) {
$html = "<table border=\"1\">
<tr>
<th>REF.</th>
<th>FAVORECIDO</th>
<th>DEBITO</th>
</tr>";
while ($row = $sql->fetch_object()) {
$html .= "<tr>
<td>{$row->refer}</td>
<td>{$row->favorecido}</td>
<td>{$row->favorecido}</td>
</tr>";
/*
// aqui não sei como separar, por uma linha com a DATA conforme exemplo acima
if ($row->data) {
$html .= "<tr>
<td rowspan="3">Data: {$row->data}</td>
</tr>";
}
*/
}
$html .= "</table>";
echo $html;
}
My test array
$data[] = array(
'data' => '2015-02-05',
'refer' => 'X741852',
'favorecido' => 'MARIA',
'debito' => '2.500'
);
$data[] = array(
'data' => '2015-02-05',
'refer' => 'B890656',
'favorecido' => 'EDUARDA',
'debito' => '500'
);
$data[] = array(
'data' => '2015-02-18',
'refer' => 'CK546045',
'favorecido' => 'JOAO',
'debito' => '42.050'
);
$data[] = array(
'data' => '2014-06-09',
'refer' => 'FE55852',
'favorecido' => 'CHARLES',
'debito' => '28.500'
);
$data[] = array(
'data' => '2014-06-09',
'refer' => 'X741852',
'favorecido' => 'VIVIANE',
'debito' => '74.2500'
);
Possible duplicate of Create an array separated by date groups
– Guilherme Lautert
@smigol explain better the step he is in and the difficulty, because otherwise it is the same as the other. At least explain why the other did not solve as you expected, and why are not able to use the data to assemble the report, etc.
– Bacco
I am personally editing
– smigol
@smigol see if this is what you want: http://answall.com/questions/105060/ In particular the 2nd part of my reply, which shows how to create the title when changes a certain value.
– Bacco