What's new

Navbar

loktoy

Eternal Poster
Joined
Oct 20, 2014
Posts
1,166
Solutions
2
Reaction
103
Points
496
Age
30
may problima po ako sa navbar ko kapag inoopen ko lang yun navbar.php ko ok yun dropdown button nya..

pero

kapag na include ko na sya sa ibang files.. like index.php

di n po gumagana yun dropdown button po..

ito po code ko

<?php

session_start();

include "../config/config.php";

if(isset($_SESSION['id'])){

$user_id = $_SESSION['id'];

$_GET_RECORD = mysqli_query($con,"SELECT * FROM registration WHERE id = '$user_id' ");

while($row_edit = mysqli_fetch_assoc($_GET_RECORD)) {

$payee_name = $row_edit['payee_name'];
$email_address = $row_edit['email_address'];
$username = $row_edit['username'];
$password = $row_edit['password'];

}

}else {
echo "You must login first! <a href = '../login.php'>Login now! </a>";
}


?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X_UA-Compatible" content ="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="../css/bootstrap.css" rel="stylesheet">
<!-- <link href="../css/style.css" rel="stylesheet"> -->
<script src="../js/bootstrap.bundle.js"></script>
</head>

<body class="m-0 border-0 bd-example m-0 border-0 ">
<!-- Example Code -->

<nav class="navbar navbar-expand-sm p-0 " style="background:gray;">
<div class="container">
<a class="navbar-brand" href="#">Navbar</a>
<button
class="navbar-toggler" style="height:25px; width:35px;"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
<span class="navbar-toggler-icon" style="height:10px; width:15px;"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
role="button"
data-bs-toggle="dropdown"
aria-expanded="false"
Tracking
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">DTS</a></li>
<li><a class="dropdown-item" href="#">LDDAP_ADA</a></li>
<li><hr class="dropdown-divider" /></li>
<li>
<a class="dropdown-item" href="#">LDDAP-ADA</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link ">About</a>
</li>
</ul>
<form class="d-flex" role="search">
<input
class="form-control me-2" style="height:30px;"
type="search"
placeholder="Search"
aria-label="Search"
/>
<button class="btn btn-outline-success pt-1 me-3" style="height:30px;" type="submit">
<h6>Search</h6>
</button>
</form>
<div class="dropdown">
<a href="#" class="d-flex align-items-center link-body-emphasis text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<img src="../img/eslava.jpg" alt="" width="50" height="45" class=" p-1 me-2 rounded-5">
<strong><?php echo $username; ?></strong>
</a>
<ul class="dropdown-menu text-small shadow">
<li><a class="dropdown-item" href="#"></a></li>
<li><a class="dropdown-item" href="#">Settings</a></li>
<li><a class="dropdown-item" href="#">Edit Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="../login.php">Sign out</a></li>
</ul>
</div>
</div>
</div>
</nav >

<!-- End Example Code -->
</body>
</html>
 
Based on your code, it seems that you are using Bootstrap for your navbar. The issue you are facing is that the dropdown button is not working when you include the navbar.php file in other files like index.php.

One possible reason for this issue is that you are not including the necessary Bootstrap JavaScript file in the other files where you include the navbar.php file. The dropdown functionality in Bootstrap requires the Bootstrap JavaScript file to work properly.

To fix this issue, make sure you include the following line of code in the other files where you include the navbar.php file:

HTML:
<script src="../js/bootstrap.bundle.js"></script>

This line of code includes the Bootstrap JavaScript file, which is required for the dropdown functionality to work.

Additionally, make sure that you have included the necessary CSS files for Bootstrap in the other files as well. You have already included the Bootstrap CSS file in the navbar.php file with the following line of code:

HTML:
<link href="../css/bootstrap.css" rel="stylesheet">

Make sure you include this line of code in the other files as well to ensure that the Bootstrap styles are applied correctly.

By including the Bootstrap JavaScript and CSS files in your other files, the dropdown functionality should work properly even when you include the navbar.php file.
 

Similar threads

Back
Top