Я работаю над выпадающим меню, в котором элементы - это строки из таблицы, называемые уведомлениями, каждая строка имеет столбец типа, а каждый тип имеет определенный c вывод (эхо), поэтому каждая строка выводится как элемент в Меню, которое я зациклил для каждого элемента в массиве MySQL, но когда я делаю эти элементы, в раскрывающемся меню они отображаются, но они пусты следующим образом: -
![ScreenShot](https://i.stack.imgur.com/qdV8X.png)
Код: -
// notifications function here //
// unreaded notifications count to echo in the bootstrap4 badge //
$unreadednotifications = "SELECT * from `notifications` where `status` = 'unread' order by `date` DESC";
$unreadedcount = count(fetchAll($unreadednotifications));
// all notifications to sort in the dropdown menu //
$notifications = "SELECT * FROM `notifications` WHERE accountid = '8' ORDER BY `date` DESC";
$notificationscount = count(fetchAll($notifications));
// notification function ends here//
<li class="nav-item dropdown">
<a class="nav-link" href="#" id="notificationsdrop" onclick="badgefade()" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div style="font-size: 12px;"><i class="fa fa-bell fa-3x bell" aria-hidden="true"></i><?if($unreadedcount > 0){echo'<span class="badge badge-notify" id="notificationsBadge" style="font-size:15px;">'.$unreadedcount.'</span>';}?></div></a>
<div class="dropdown-menu notifications" aria-labelledby="notificationsdrop">
<? if(count(fetchAll($notifications)) > 0){
foreach(fetchAll($notifications) as $i){
?>
<a class="dropdown-item" href="view.php?id=<?php echo $i['id'] ?>" style="<? if($i['status']==['unread']){
echo"font-weight:bold;";
}?>">
<?
if ($i['type']==['socialalert']){
echo'Someone Followed You';
}
?>
</a>
<?}}?>
</div>
</li>
обновление: добавлена функция. php: -
function fetchAll($query){
$con = new PDO(DBINFO, DBUSER, DBPASS);
$stmt = $con->query($query);
return $stmt->fetchAll();
}
function performQuery($query){
$con = new PDO(DBINFO, DBUSER, DBPASS);
$stmt = $con->prepare($query);
if($stmt->execute()){
return true;
}else{
return false;
}
}
?>