You need to use something unique in your accordion id
E.G.
<div class="accordion" id="accordionExample">
<?php
$i = 1;
$user = $_SESSION['auth_user']['user_id'];
$query = "SELECT * FROM task WHERE user_id = '$user' ORDER BY datetime DESC";
$query_run = mysqli_query($con, $query);
while ($res = mysqli_fetch_array($query_run))
{
?>
<div class="card">
<div class="card-header" id="headingOne<?php echo $i ?>">
<h4 class="mb-0">
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapseOne<?php echo $i ?>" aria-expanded="true" aria-controls="collapseOne<?php echo $i ?>">
<div class="container">
<div class="row">
<div class="col">
<?php echo $i ?>. <?php echo $res['domain']; ?> (<?php echo $res['datetime']; ?>)
</div>
</div>
</div>
</button>
</h4>
</div>
<div id="collapseOne<?php echo $i ?>" class="collapse" aria-labelledby="headingOne<?php echo $i ?>" data-parent="#accordionExample">
<div class="card-body">
</div>
</div>
</div>
<?php $i++; } ?>
</div>
12
solved Dynamically fetch content inside accordion from database in php [closed]