w3 redirect html code example

Example 1: redirect javascript

// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

Example 2: window relocation from navbar

$query = "select* from main_menus";
            $result = mysqli_query($con,$query);

            while($row = mysqli_fetch_assoc($result)) {
                $main_menus_id = $row['menu_id'];
                $menu_title = $row['menu_title'];
                $menu_url = $row['menu_url'];
          ?>
        <li class="nav-item ">
          <a href="<?php echo $menu_url ?>"><?php echo $menu_title ?></a>
        </li>
        <?php 
      }
      ?>
      </ul>
    </div>`