dongmangji0950 2019-07-08 19:17
浏览 50

单击列表中的项目后更新通知的状态

 <?php
             define ("SECRETKEY", "Hasrd");
            $d_id = $_SESSION['deptID'];
            $aid=$_SESSION['alogin'];
            $sql="select * from notifications where  
                    uid!= $aid and status=1 
                    and (PostID in(select PostID
                            from Posts, groups, Courses,persons 
                    where Groups.CourseID = Courses.CourseID
                    and Posts.GroupID = Groups.GroupID and 
                    DeptID = $d_id)

                    or commentID in(
                        select CommentID 
                            from Comments, Posts, groups, Courses 
                    where Comments.PostID = Posts.PostID 
                    and Groups.CourseID = Courses.CourseID
                    and Posts.GroupID = Groups.GroupID and 
                    DeptID = $d_id)

                    )
                    order by notid Desc ";
            $query = $dbh -> prepare($sql);
            $query->execute();
            $results=$query->fetchAll(PDO::FETCH_OBJ);
            if($query->rowCount() > 0)
            {
              $count=$query->rowCount(); ?>
              <span class='badge badge-danger'> <?php echo $count; ?> </span>
              <?php
              echo "<div class='dropdown-menu dropdown-menu-right' aria-labelledby='alertsDropdown'>";

            foreach($results as $result)
            {   

                $sql1="select GroupID,FirstName,LastName from posts,persons where posts.PID=persons.PID  and PostID='$result->PostID'";
                $query1 = $dbh -> prepare($sql1);
                $query1->execute();  
                $row=$query1->fetchAll(PDO::FETCH_OBJ);
                if($query1->rowCount() > 0)
                {

                 foreach($row as $r)
                 {  
              ?>
        </a>
             <?php 
             if($result->PostID!=null)
             { 

                ?>
               <a class="dropdown-item" href="controlgroup.php?groupid=<?php echo htmlentities(openssl_encrypt($r->GroupID,"AES-128-ECB", SECRETKEY)); ?>">New Post is added by <?php echo $r->FirstName;?> <?php echo $r->LastName;?> <br><?php echo $result->notificationdatetime;?></a><hr>
            <?php }}}

             else if($result->CommentID!=null)
             {  
                $sql2="select CommentID,GroupID,FirstName,LastName from comments,posts,persons where comments.PostID=posts.PostID and persons.PID=comments.PID  and comments.CommentID='$result->CommentID'";
                $query2 = $dbh -> prepare($sql2);
                $query2->execute();  
                $row1=$query2->fetchAll(PDO::FETCH_OBJ);
                if($query2->rowCount() > 0)
                {

                 foreach($row1 as $r1)
                 {  
                    if($r1->GroupID!=$d_id)
                    {
                    ?> 
                <a class='dropdown-item' href="controlgroup.php?groupid=<?php echo htmlentities(openssl_encrypt($r1->GroupID,"AES-128-ECB", SECRETKEY)); ?>">New Comment is added by <?php echo $r1->FirstName;?> <?php echo $r1->LastName;?> <br><?php echo $result->notificationdatetime; ?></a><hr>
                <?php } else if($r1->GroupID==$d_id){ ?>

                  <a class="dropdown-item" href="controlpost.php">New Comment is added by <?php echo $r1->FirstName;?> <?php echo $r1->LastName;?> <br><?php echo $result->notificationdatetime; ?></a><hr>    

             <?php }}}}

             else if($result->reportid!=null)
             { ?>

            <a class="dropdown-item" href="controlreport.php">New report is added</a>$result->notificationdatetime<hr>";
           <?php  }}}

            ?>

All what I need is when I click any Item from the Notification dropdown the status of the notification I clicked become equal zero in the table notification How can I make this? I try many things in php, jquery and ajax and I didn't return any result about what I need.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题