I have a big problem because I don’t know how to correctly write the second query. I ask for help.
The table vt_personale has
user_nome
user_cognome
user_postazione
user_coordinatore
The table vt_formaz_corsi has
user_nome (the same of vt_personale but split user_nome e user_cognome)
and other values
<div class="card-datatable table-responsive pt-0 p-3 w-100" >
<table id="emp-table" class="datatables-basic table table-bordered p-3 w-100" width="100%">
<thead>
<tr>
<th>Cognome Nome</th>
<th>Postazione</th>
<th>Coordinatore</th>
<th style="max-width:220px">Corso</th>
<th>Tipo</th>
<th>Ultimo corso</th>
<th>Scadenza</th>
<th></th>
<th></th>
</tr>
<tr>
<th>Cognome Nome</th>
<th>Postazione</th>
<th>Coordinatore</th>
<th style="max-width:220px">Corso</th>
<th>Tipo</th>
<th>Ultimo corso</th>
<th>Scadenza</th>
<th></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>Cognome Nome </th>
<th>Postazione</th>
<th>Coordinatore</th>
<th style="max-width:220px">Corso</th>
<th>Tipo</th>
<th>Ultimo corso</th>
<th>Scadenza</th>
<th></th>
<th></th>
</tr>
</tfoot>
</thead>
<tbody class="table-border-bottom-0" id="myTable">
<?php $num = 0;
include_once 'main.php';
$stmt = $DB_con->prepare('SELECT * FROM vt_formaz_corsi ORDER BY user_nome ASC');
$stmt->execute();
$Count= $stmt->rowCount();
if($stmt->rowCount() > 0){
while($row=$stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
?>
<tr>
<td class="center"><?php echo $row['user_nome']; ?></td>
<?php // this is the second query that not read
$stmtpersonale = $DB_con->prepare("SELECT * FROM vt_personale as P INNER JOIN vt_formaz_corsi as C WHERE CONCAT_WS(P.user_cognome, ' ', P.user_nome) = '.(string)$row['user_nome'].'");
$stmtpersonale->execute(); $Countpers= $stmtpersonale->rowCount();
if($stmtpersonale->rowCount() > 0) {
while($row4=$stmtpersonale->fetch(PDO::FETCH_ASSOC)){
extract($row4);
?>
<td class="center"><?php echo $row4['user_postazione']; ?></td>
<td class="center"><?php echo $row4['user_coordinatore']; ?></td>
<?php } } ?>
<td class="center p-3 w-100" style="width:50%"><?php echo $row['user_corso']; ?></td>
<td class="center"><?php echo $row['user_residenziale']; ?></td>
<td class="center"><?php echo $result; ?></td>
<td class="center"> <?php echo $resultscadenza;?></td>
<td class="center"> <?php echo $$differenza;?></td>
</tr>
<?php } }else{?>
<div class="col-xs-12">
<div class="alert alert-warning"><span class="glyphicon glyphicon-info-sign"></span> Nessun dato trovato ... </div>
</div>
<?php}?>
<?phpob_end_flush();?>
</tbody>
</table>
</div>