我在我的数据库中有两个标题,我需要一个while循环,我想显示多个崩溃标题我在数据库中有多少标题记录

And this is the code.

 <body>
    <br>
    <div class="card">
    <?php
        while($row=mysqli_fetch_assoc($result))
        {
            echo '<div class="card-header">';
            echo '<h5 class="mb-0">';
            echo '<button class="btn btn-link" type="button" data-toggle="collapse"  
            aria-expanded="true" aria-controls="collapseOne">';

            echo $row['title'];

           echo '</button>';
           echo '</h5>';
           echo '</div>';
           echo '</div>';
       }
   ?>
  </div>
</body>

but now it display the second record with one collapse title, it must dispaly two title with two collapse title.

Place the main card div within your while loop:

<body>
<br>
<?php
    while($row=mysqli_fetch_assoc($result))
    {
        echo '<div class="card">';
        echo '<div class="card-header">';
        echo '<h5 class="mb-0">';
        echo '<button class="btn btn-link" type="button" data-toggle="collapse"  
        aria-expanded="true" aria-controls="collapseOne">';

        echo $row['title'];

       echo '</button>';
       echo '</h5>';
       echo '</div>';
       echo '</div>';
   }
?>
</body>