我正在尝试抓取一条消息,然后在我的通知标签下显示它,但它没有显示消息我正在尝试从两个表成员表和通知表中进行INNER JOIN这是我的表格结构已经建立。
会员表
MEMBERID,
用户名,
ownerIP,
以及更多
现在在通知表中,这就是我所拥有的。
通知
ID
MEMBERID
消息
状态
这是我的PHP代码。
<li class="dropdown hidden-xs">
<a href="#" data-target="#" class="dropdown-toggle waves-effect waves-light" data-toggle="dropdown" aria-expanded="true">
<i class="icon-bell"></i> <span class="badge badge-xs badge-danger">3</span>
</a>
<ul class="dropdown-menu dropdown-menu-lg">
<?php
// Load Notfications
$loadNotfications = $db->fetchAll("SELECT * FROM notfications INNER JOIN members.memberID ON notfications.memberID = members.memberID WHERE memberID = '".$memberID."'");
if($loadNotfications) {
foreach($loadNotfications as $loadNotfication) {
$id = $loadNotfication['id'];
$memberID = $loadNotfication['memberID'];
$message = $loadNotfication['message'];
$status = $loadNotfication['status'];
?>
<li class="notifi-title"><span class="label label-default pull-right">New 3</span>Notification</li>
<li class="list-group nicescroll notification-list">
<!-- list item-->
<a href="javascript:void(0);" class="list-group-item">
<div class="media">
<div class="pull-left p-r-10">
<em class="fa fa-cog fa-2x text-custom"></em>
</div>
<div class="media-body">
<h5 class="media-heading">New settings</h5>
<p class="m-0">
<small><?php echo $message; ?></small>
</p>
</div>
</div>
</a>
</li>
<li>
<a href="javascript:void(0);" class="list-group-item text-right">
<small class="font-600">See all notifications</small>
</a>
</li>
<?php
}
}
?>
</ul>
</li>
我需要帮助,任何人都可以帮助我。
答案 0 :(得分:0)
我想你可以查一下这句话:
$loadNotfications = $db->fetchAll("SELECT * FROM notfications INNER JOIN members.memberID ON notfications.memberID = members.memberID WHERE members.memberID = '".$memberID."'");
我已将members.memberId
放在WHERE子句之后。我认为它可行。
答案 1 :(得分:0)
所以我解决了我的问题,这就是我要解决的问题
// Load Notfications
$loadNotifications = $db->fetchAll("SELECT * FROM notifications WHERE memberID='{$myID}' AND status = 1 ORDER BY id DESC LIMIT 25");
if($loadNotifications) {
foreach($loadNotifications as $loadNotification) {
$id = $loadNotification['id'];
$memberID = $loadNotification['memberID'];
$message = $loadNotification['message'];
$status = $loadNotification['status'];
$subject = $loadNotification['subject'];
?>
<!-- list item-->
<a href="javascript:void(0);" class="list-group-item">
<div class="media">
<div class="pull-left p-r-10">
<em class="fa fa-bell fa-2x text-custom"></em>
</div>
<div class="media-body">
<h5 class="media-heading"><?php echo $subject; ?></h5>
<p class="m-0" style="white-space: normal;">
<small><?php echo $message; ?></small>
</p>
</div>
</div>
</a>
<?php
}
} else {
echo '<span class="text-center">There are currently no unread notifications.</span>';
}
?>
</li>