我想显示登录我网站的数据库的名字 - 而不是用户的用户名。 这是我的数据库的图片,所以我已经尝试过查询,但总是抱怨一个未定义的索引
这是导航栏出勤,只有另一个导航栏,但我只举例说明
navbar_attendance.php
def staff_visible(self):
queryset = self.filter(Q(staff_visible=True))
return queryset
def visible(self):
queryset = self.filter(is_active=True)
return queryset
session.php文件
Product.objects.staff_visible()
答案 0 :(得分:-1)
您好,您需要将此查询放在要显示名字的位置。
<?php if(!isset($_SESSION)){
session_start();
} ?>
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="dashboard.php"><i class="icon-home icon-large"></i> Home</a></li>
<li><a href="attendance.php"><i class="icon-home icon-large"></i> Attendance Info</a></li>
<li><a href="users.php"><i class="icon-user icon-large"></i> Users</a></li>
<?php
include('dropdown.php');
?>
<li><a href="books.php"><i class="icon-book icon-large"></i> Books</a></li>
<li><a href="member.php"><i class="icon-group icon-large"></i> Member</a></li>
<li ><a href="archive.php"><i class="icon-list-alt icon-large"></i> Archive</a></li>
<li><a href="utility.php"><i class="icon-cog icon-large"></i> Utilities</a></li>
<li><a href="logout.php"><i class="icon-signout icon-large"></i> Logout</a></li>
</ul>
<div class="pull-right">
<div class="admin">Welcome: <?php
if(isset($_SESSION['id'])){
$sql="SELECT firstname FROM TABLENAME WHERE user_id='$session_id'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0)
{
while($row= mysqli_fetch_assoc($result)){
echo $row['firstname'];
}
}
}
?></div>
</div>
</div>
</div>
</div>
</div>
<?php include('search_form.php'); ?>`