0
In this script a have an expandable table showing by GROUP by nome
, that when we click on the line, it will expand, showing a second table listing all the lines referring to the GROUP by nome
.
Closed Table:
Open Table: How it should show
What I don’t know how to do is that this daughter table shows all the records referring to the mother table that show in GROUP by nome
.
<?php
include"config.php";
?>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#report > tbody > tr").hide();
$("#report > tbody > tr:even").addClass("odd").show();
$("#report tr.odd").click(function () {
$(this).next("tr").toggle();
$(this).find(".arrow").toggleClass("up");
});
});
</script>
</head>
<body>
<table id="report" border="1" style="width: 50%;">
<thead>
<tr>
<th style="width: 20%;">Id</th>
<th>Cliente</th>
<th>Data</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM a_finan GROUP by cliente ";
$result = $PDO->query( $sql );
$linha = $result->fetchAll();
foreach ($linha as $row) {
$id_empresa = $row['id_empresa'];
$id_finan = $row['id_finan'];
$start = $row['start'];
$tipo = $row['tipo'];
$valor = $row['valor'];
$os = $row['os'];
$cliente = $row['cliente'];
?>
<tr>
<td> <a href="#"><?php echo $id_finan?> Mostrar Faturas</a></td>
<td><?php echo $nome_fan?></td>
<td>30,00</td>
</tr>
<tr>
<td colspan="5">
<table>
<tr>
<td>
</td>
<td>OS</td>
<td>Cliente</td>
<td>Data</td>
<td>Centro Custo</td>
<td>Status Transacação</td>
<td>valor</td>
<td>Acao</td>
</tr>
<tr>
<td>
<input type="checkbox" />
</td>
<td><?php echo $id_finan?></td>
<td><?echo $cliente?></td>
<td>12/10/2015</td>
<td>xxx</td>
<td>xxx</td>
<td>30,00</td>
<td>Del</td>
</tr>
</table>
</td>
</tr>
<?}?>
</tbody>
</table>
</body>
I didn’t understand anything... what’s the question anyway?
– Jorge B.
In the table above there are two records with id 1037 and 1043 they are grouped by name. so far all right.... the problem and how to do when I click on the "show invoices" link when expanding the line show the disaggregated records here is the script working without the https://jsfiddle.net/gxr47dqr/1selects/
– Fabio Henrique
Fabio this fiddle is as it should be or as it currently is?
– Jorge B.
he’s just an example of what this should be like in practice
– Fabio Henrique
What do you mean, disaggregated ? I couldn’t understand exactly what the problem is.
– Edilson
In the parent table in the image above it closes a select using a Group by name, grouping all rows with the same name. What I want and that when clicking on the link while expanding the line show the lines that were grouped by Group by name.
– Fabio Henrique
Do you have the grouped list that would be customers, each customer has their correct ID? If correct, when you click on the link to "show invoices" click an onclick JS function on the link and do an AJAX by going to the search the client ID, with this ID you select the invoices and assemble the HTML by AJAX.
– Mayron Ceccon
How are your tables structured? What are the fields and what values will be searched for? Knowing how they work makes it easier to help.
– Felipe Umpierre
@Mayronceccon unfortunately know nothing of javascript and ajax.
– Fabio Henrique
Ola amigo thinks of a simple and unique table. where the fields are ( id,client,date,tel,status,value). In the parent row show (id, client, value) grouped by the client column. and in the expanded line show all ( id,customer,date,tel,status,value) referring to the grouped client.
– Fabio Henrique
@Mayronceccon converted your response into comment. If you want you can give a complete answer, with code examples for AP to understand the problem and the solution.
– Sergio