<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// include mysql database configuration file
include_once 'db.php';

$query = "SELECT id,date_import,filename,last,count FROM importation ORDER BY id DESC;";
 
$result = mysqli_query($conn, $query);
$tr="";
if ($result->num_rows > 0)
{
    $i=1;
    
    foreach ($result as $row)
    {
        if ($row['last']==True)
        {
            //ajout du bouton de suppression
            $tr.="<tr><td>".$row['date_import']."</td>
            <td>".$row['filename']."</td>
            <td>".$row['count']."</td>
            <td><button type='button' onclick='download(".$row['id'].");' class='btn btn-success' aria-label='Left Align'>  <i class='fa-solid fa-download'></i></td>
            <td><button type='button' onclick='remove(".$row['id'].");' class='btn btn-danger' aria-label='Left Align'>  <i class='fa-solid fa-trash'></i></td></tr>";        
        }
        else
        {
            $tr.="<tr><td>".$row['date_import']."</td>
            <td>".$row['filename']."</td>
            <td>".$row['count']."</td>
            <td><button type='button' onclick='download(".$row['id'].");'class='btn btn-success' aria-label='Left Align'>  <i class='fa-solid fa-download'></i></td>
            <td></td></tr>";
        }
    
    $i++;
}
}

?>