UPDATE 2
riepilogo-loop.php:
<?php
include '../../utente/index.php';
$link = mysqli_connect("localhost", "user", password, "database");
$result_array = array();
$query = "SELECT usuario, fecha, codice, articolo, quantita, note, stato FROM spesa WHERE usuario = '".$username ."'";
$result = mysqli_query($link, $query);
if (mysqli_num_rows($result) > 0) {
$item_array = array();
while($row = mysqli_fetch_assoc($result)) {
$result_array[]=$row;
}
}
echo json_encode($result_array);
$link->close();
?>
Riepilogo.php
<?php
$content = "
<div class='row'>
<div class='col-xs-12'>
<div class='box'>
<div class='box-header'>
<h3 class='box-title'>Le tue spese</h3>
</div>
<!-- /.box-header -->
<div class='box-body'>
<table id='spesa' class='table table-bordered table-hover'>
<thead>
<tr>
<th>Dipendente</th>
<th>Data</th>
<th>Codice Prodotto</th>
<th>Descrizione Prodotto</th>
<th>Quantità</th>
<th>Stato</th>
<th>Note</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
<!-- /.box-body -->
</div>
<div>
<span>
<p><a href='create.php'>Nuova Spesa</a></p>
</span>
</div>
<!-- /.box -->
</div>
</div>";
include('index.php');
?>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: '../api/config/riepilogo-loop.php',
type: 'get',
dataType: 'JSON',
success: function(response){
var len = response.length;
for(var i=0; i<len; i++){
var usuario = response[i].usuario;
var fecha = response[i].fecha;
var codice = response[i].codice;
var articolo = response[i].articolo;
var quantita = response[i].quantita;
var stato = response[i].stato;
var note = response[i].note;
var tr_str = "<tr>" +
"<td align='center'>" + usuario + "</td>" +
"<td align='center'>" + fecha + "</td>" +
"<td align='center'>" + codice + "</td>" +
"<td align='center'>" + articolo + "</td>" +
"<td align='center'>" + quantita + "</td>" +
"<td align='center'>" + stato + "</td>" +
"<td align='center'>" + note + "</td>" +
"</tr>";
$("#spesa tbody").append(tr_str);
}
}
});
});
</script>