I have two tables (both related by their ID):
Socios: Socios_carga
------------ --------------
ID ID
Nombre Nombre
RUT RUT
Then with INNER JOIN
I generate the query of these related tables
$query="SELECT socios.nombre, socios_carga.nombre_carga, socios_carga.rut_carga FROM socios INNER JOIN socios_carga on socios.id=socios_carga.id_carga ORDER BY socios.nombre";
$resource = $conn->query($query);
$total = $resource->num_rows;
and it shows me something like this:
Partner1 Load1
Partner1 Load2
Partner1 Load3
Partner2 Load1
Partner2 Load2
And what I need is for you to show me the following in an HTML table:
Socio1
Carga1
Carga2
Carga3
Socio2
Carga1
Carga2
I do not know if this is achieved by adding something to the query or by adding some code to PHP.
HTML and PHP code showing the query:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Titular</th>
<th>Nombre</th>
<th>Rut</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
<tr>
<?php while ($row = $resource->fetch_assoc()){?>
<td><?php echo $row[nombre]?></td>
<tr>
<td><?php echo $row[nombre_carga]?></td>
<td><?php echo $row[rut_carga]?></td>
</tr>
</tr>
<?}?>
</tbody>
</table>
================================================================================================= ==============
Table 'partners_load'
As you can see the ID = 9 of the partner has no load and the ID = 11 has only 2 charges