what is most efficient way to use sidebar menu? : So if i have to make have a sidebar menu like schools website, in which active clicked link is highlighted after the page loads.it uses individual pages like

        <a target="_top" href="default.asp">HTML HOME</a>
    <a target="_top" href="html_intro.asp">HTML Introduction</a>
    <a target="_top" href="html_editors.asp">HTML Editors</a>
    <a target="_top" href="html_basic.asp">HTML Basic</a>
    <a target="_top" href="html_elements.asp">HTML Elements</a>

but the one i built on my own is created with php so what happens in that one is the title or name of menu item is changed to lowercase and saved in database in same  row called class which is used for active link highlighting. so what happens when sidebar link is clicked is only content of summary div's content
 (which is right to sidebar) is changed while sidebar and navigation bar stays same. so it stays on the same page and retrieves data from database and puts in summary div.

    <body class='noPadding'>
         <div class='bigNav'>             <!-- top navbar -->
              <img src="images/logo2.png"/>
         </div>
    
         <?php
         if(isset($_GET['subject'])){
             $subject=$_GET['subject'];
    

         ?>
         <div class='container'>
            <div class='leftLayout' style='padding-top:70px;background-color:#EBEBEB'>
                <ul class="fullFit">
                  <?php
                     $query="SELECT * FROM `study` WHERE `subject`='$subject'";
                     $run=mysqli_query($conn,$query);
                     while($row=mysqli_fetch_array($run)){
                           $topic=$row['topic'];
                           $class=$row['class'];  ?>
    
                                 <li  class="<?php echo $class?>">
                                   <a href='<?php echo $sitename ?>/web.php?subject=<?php echo $subject?>&topic=<?php echo $class?>'>
                                       <?php echo $topic?>
                                   </a>
                                 </li>
    
                      <?php  }  ?>
    
                </ul>
            </div>
    
         <?php
         if(isset($_GET['topic'])) {
             $active_id=$_GET['topic'];
             $topic=$_GET['topic'];
             $query="SELECT summary FROM `study` WHERE `class`='$active_id'";
             $run=mysqli_query($conn,$query);
             $row=mysqli_fetch_array($run);
             $summary=$row[0];
          ?>
            <div class='summary'> <?php echo $summary ?> </div>
          <?php } ?>
    
    
         </div>
      <script>
    
          $(document).ready(function(){
            $(".<?php echo $active_id ?>").addClass("current");
            });
    
      </script>
    
    <?php  }  ?>
    
    </body> 

And also if i have to make individual pages instead like many websites including W3schools does,do i have to create a new file each time and include navigation bar and sidebar(which are supposed to stay same on every link) in each file?
how do they manage it?