In this script one I have an expandable table Showing by GROUP by nome
, that when we click on the line, will expand, showing a second table listing all the lines referring to GROUP by nome
.
Closed Table:
OpenTable:HowshouldIshow
WhatIdonotknowhowtodoisforthischildtabletoshowallrecordsfortheparenttablethatshowinGROUPbynome
.
<?phpinclude"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>