I made a data base with head, sub_head, item 1,item2 and want the display to be
Head
Subhead  Item1        Item2
subhead   Item1        Item2
Head
Subhead  Item1        Item2
subhead   Item1        Item2…  wher the subhead would be two or more.
Currently the code is correctly
Head
Subhead  Item1        Item2
subhead   Item1        Item2
but ignoring the rest of data.
<?php 
  $sum=0;
    $sql = "SELECT * FROM budget ";
    $result_data=mysqli_query($conn, $sql);
       while ($row_data = mysqli_fetch_assoc($result_data)) {
        $head=$row_data['head'];
            echo "<tr>";
            echo "<td class='tg-0pky'>" .$head. "</td>";
            echo "</tr>";
            $sql = "SELECT * FROM budget WHERE head='$head'";
            $result_data=mysqli_query($conn, $sql);
            while ($row_data = mysqli_fetch_assoc($result_data)) {
            $sub_head=$row_data['sub_head'];
            $sub_budget=$row_data["sub_budget"];
            $budget_paydate=$row_data["budget_paydate"];
            $sub_actual=$row_data["sub_actual"];
            $sub_date=$row_data["sub_date"];
            $remarks=$row_data["remarks"];
            echo "<tr>";
            echo "<td class='tg-0pky'>" .$sub_head. "</td>";
            echo "<td class='tg-0pky'>" .$budget_paydate. "</td>";
            echo "<td class='tg-0pky'>" .$sub_budget. "</td>";
            echo "<td class='tg-dvpl'>" .$sub_actual. "</td>";
            echo "<td class='tg-dvpl'>" .$sub_date. "</td>";
            echo "<td class='tg-dvpl'>" .$remarks. "</td>";
            echo "</tr>";
                     }
    
      
           }   
 
      
    