что мне нужно добавить на эту страницу, чтобы вставить новый комментарий, учитывая, что на одной странице много постов и с помощью btn comment_postid - PullRequest
0 голосов
/ 11 мая 2019

<?php
  include_once("inc/head.php");
  include_once("inc/nav.php");
?>
<?php 
if(isset($_REQUEST['eid']))
{
    $eid=intval($_GET['eid']);
    $status="0";
    $sql4 = "UPDATE comments SET CommentStatus=:status WHERE  CommentID=:eid";
    $query = $dbh->prepare($sql4);
    $query -> bindParam(':status',$status, PDO::PARAM_STR);
    $query-> bindParam(':eid',$eid, PDO::PARAM_STR);
    $query -> execute();
    echo "<script>alert('Comment Successfully Deleted');</script>";
}
?>
 <div id="wrapper">
<?php
  include_once("inc/side.php");
?>
     <div id="content-wrapper">

      <div class="container-fluid">
  <?php //begin section?>
        
  <div class="container-fluid gedf-wrapper">
    
   <?php
      $d_id = $_SESSION['deptID'];
      $d_name = $_SESSION['deptName'];
      
      $sql = "select PostBody, PostDateTime, FirstName, LastName 
          from posts, persons, groups, Courses
          where posts.PID=persons.PID 
            and posts.GroupID=groups.GroupID 
            and Courses.CourseID = Groups.CourseID
            and Courses.CourseName =:cname
            and PostStatus=1 order by PostDateTime desc ";
                    $query = $dbh -> prepare($sql);
                    $query->bindParam(':cname',$d_name, PDO::PARAM_STR);
                    $query->execute();
                    $results=$query->fetchAll(PDO::FETCH_OBJ);
                    if($query->rowCount() > 0)
                    {
                    foreach($results as $result)
                    {  ?>
      <div class="row">
        <div class="col-md-12  gedf-main">
                <!--- \\\\\\\Post-->
                    <div class="card gedf-card">
                    <div class="card-header">
                        <div class="d-flex justify-content-between align-items-center">
                            <div class="d-flex justify-content-between align-items-center">
                                <div class="mr-2">
                                    <img class="rounded-circle" width="45" src="https://picsum.photos/50/50" alt="">
                                </div>
                                <div class="ml-2">
                                    <div class="h5 m-0"><?php echo htmlentities($result->FirstName);?> <?php echo htmlentities($result->LastName);?></div>
                                </div>
                            </div>
                        </div>    
                    </div>
                    <div class="card-body">
                        <div class="text-muted h7 mb-2"> <i class="fa fa-clock-o"></i><?php echo htmlentities($result->PostDateTime);?></div>

                        <p class="card-text">
                          
                           <?php echo htmlentities($result->PostBody);?>
                        </p>
                        <!--<p><img src="">-->
                    </div>
                    <hr>
                    <div class="form-group">
                          <textarea class="form-control" id="comment" name="commentbody" placeholder="Comment...."></textarea>
                          <button class="btn btn-primary">Commment</button>
                    </div>
                    
                       <?php
      
                      $sid=$_SESSION['login'];
                      $sql1="select CommentDateTime, CommentBody, FirstName, LastName,CommentID,CommentStatus
                      from persons, comments, posts
                      where persons.PID=comments.PID
                      and comments.PID=:sid
                      and comments.PostID=posts.PostID
                      order by CommentDateTime desc";
                    $query1 = $dbh -> prepare($sql1);
                    $query1->bindParam(':sid',$sid, PDO::PARAM_STR);
                    //$query1->bindParam(':cname',$d_name, PDO::PARAM_STR);
                    $query1->execute();
                    $results1=$query1->fetchAll(PDO::FETCH_OBJ);
                    if($query1->rowCount() > 0)
                    {
                    foreach($results1 as $result1)
                    {  ?>
                    <hr>
                    <div class="media mb-4">
                      <div class="dropdown">
                                    <button class="btn btn-link dropdown-toggle" type="button" id="gedf-drop1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <i class="fa fa-ellipsis-h"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="gedf-drop1">
                                        <div class="h6 dropdown-header">Configuration</div>
                                        <?php 
                                            if($result1->CommentStatus== 1)
                                            { ?>
                                                  <a class="dropdown-item" href="home.php?eid=<?php echo htmlentities($result1->CommentID);?>" data-toggle="modal" data-target="#deletemodal" onclick="return confirm('Do you really want to delete?')">Delete</a>
                                          <?php  } ?>
                                                    
                        
                                      
                                    </div>
                                </div>
                      <img class="d-flex mr-3 rounded-circle" src="http://placehold.it/50x50" alt="">
                      <div class="media-body">
                        <h5 class="mt-0"><?php echo htmlentities($result1->FirstName);?> <?php echo htmlentities($result1->LastName);?></h5><div class="text-muted h7 mb-2"> <i class="fa fa-clock-o"></i><?php echo htmlentities($result1->CommentDateTime);?></div>
                           <?php echo htmlentities($result1->CommentBody);?>
                      </div>
                    </div>
                    
                    <?php }} ?>
                    
                <?php
      
                  $ssid=$_SESSION['login'];
                  $sql2="select CommentDateTime, CommentBody, FirstName, LastName
                  from persons, comments, posts
                  where persons.PID=comments.PID
                  and comments.PID!=:ssid
                  and comments.PostID=posts.PostID
                  order by CommentDateTime desc";
                    $query2 = $dbh -> prepare($sql2);
                    $query2->bindParam(':ssid',$ssid, PDO::PARAM_STR);
                    //$query1->bindParam(':cname',$d_name, PDO::PARAM_STR);
                    $query2->execute();
                    $results2=$query2->fetchAll(PDO::FETCH_OBJ);
                    if($query2->rowCount() > 0)
                    {
                    foreach($results2 as $result2)
                    {  ?>
                    <hr>
                    <div class="media mb-4">
                      <div class="dropdown">
                                    <button class="btn btn-link dropdown-toggle" type="button" id="gedf-drop1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <i class="fa fa-ellipsis-h"></i>
                                    </button>
                                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="gedf-drop1">
                                        <div class="h6 dropdown-header">Configuration</div>
                                        <a class="dropdown-item" href="#" data-toggle="modal" data-target="#reportmodal">Report</a>
                                    </div>
                                </div>
                      <img class="d-flex mr-3 rounded-circle" src="http://placehold.it/50x50" alt="">
                      <div class="media-body">
                        <h5 class="mt-0"><?php echo htmlentities($result2->FirstName);?> <?php echo htmlentities($result2->LastName);?></h5><div class="text-muted h7 mb-2"> <i class="fa fa-clock-o"></i><?php echo htmlentities($result2->CommentDateTime);?></div>
                           <?php echo htmlentities($result2->CommentBody);?>
                      </div>
                    </div>
                    <?php }} ?>
                  
                </div>
        
        
        
                <!-- Post /////-->
                
            </div>
        
    
        </div>
        <br>
        <?php }} ?>
    
    
    
    </div>
      
  
    

   
    
    

что мне нужно добавить на эту страницу, чтобы вставить новый комментарий, учитывая, что на одной странице много постов и используется btn comment_postid, затем то, что мне нужно обновить в моем коде, чтобы удалить ссылку и обновить комментарий статус до 0.

Пожалуйста, мне нужна эта помощь и большое спасибо всем, кто поможет мне, так как я не сплю в течение 3 дней в поисках решения.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...