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

时间:2019-07-08 19:17:52

标签: php

 <?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  }}}

            ?>

所有我需要的是,当我从“通知”下拉列表中单击任何项​​目时,我单击的通知的状态在表通知中变为零 我该怎么做?我在php,jquery和ajax中尝试了很多东西,但没有返回任何关于我需要的结果。

0 个答案:

没有答案