php通知页-表不显示结果

7tofc5zh  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(158)

我创建了一个通知脚本,有一个名为notificationcenter.php的页面,管理员用户可以在其中查看所有通知。它将显示哪些用户已经阅读了哪些通知、何时发布以及发布者。一切都很好,唯一的问题是当我进入notificationcenter.php页面查看所有通知时,表不会显示结果。但是,我运行if语句来检查是否有任何结果,并且没有任何错误。这是我的密码,我肯定我做了一些愚蠢的事,但我看不出来是什么,我真的很感谢任何帮助!。

//Get User ID
$id = $_SESSION['user_id'];

//Select * Notifications
$notQuery = $serviceConn->query("SELECT * FROM db759709251.notifications WHERE `not_viewedby` NOT LIKE '%$id%' ");

<h4>Nofication Center</h4>
        <?php if($notQuery->rowCount()) { ?>
          <table>
            <thead>
              <tr>
                <th scope="col">Status</th>
                <th scope="col">User</th>
                <th scope="col">Notification</th>
                <th scope="col">Date</th>
                <th scope="col">Viewed By</th>
                <th scope="col"></th>
              </tr>
            </thead>
            <tbody>
              <?php
                while ($row = $notQuery->fetch()) {
                  $notid = $row['not_id'];
                  $notUser = $row['not_user'];
                  $notMsg = $row['not_msg'];
                  $notStatus = $row['not_status'];
                  $notDate = $row['not_date'];
                  $notViewedby = $row['not_viewedby'];

              ?>
                  <tr>
                    <td style="background-color: <?php echo $statusColour; ?>" data-label="Status"><?php echo $notStatus; ?></td>
                    <td data-label="User"><?php echo $notUser; ?></td>
                    <td data-label="Notification"><?php echo $notMsg; ?></td>
                    <td data-label="Date"><?php echo $notDate; ?></td>
                    <td data-label="Viewed By"><?php echo $notViewedby; ?></td>
                    <td data-label="">
                      <form action="" method="POST">
                        <input type="hidden" name="notificationID" value="<?php echo $notid; ?>" >
                        <input type="hidden" name="notificationBy" value="<?php echo $notViewedby; ?>">
                        <input type="submit" name="read" value="Dismiss!">
                      </form>
                    </td>
                  </tr>
              <?php
                }
              ?>
            </tbody>
          </table>
        <?php } else { ?>
          <p>You currently have no notifications, please check back later.</p>
        <?php } ?>

现在很明显,中间有很多html用于样式和布局,但我认为它不够重要,因为它不应该对表的输出产生任何影响。但是正如您所看到的,if语句应该打印出没有通知并稍后再检查,理论上应该没有记录显示。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题