Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************comment_photo.php*****************************/
- <?php include("includes/header.php"); ?>
- <?php if (!$session->is_signed_in()) {redirect("login.php");} ?>
- <?php
- if(empty($_GET['id'])){
- redirect("photos.php");
- }
- $comments = Comment::find_the_comments($_GET['id']);
- $SpecificPhoto=Photo::find_by_id($_GET['id']);
- ?>
- <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
- <!-- Top Menu Items -->
- <?php include("includes/top_nav.php"); ?>
- <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
- <?php include("includes/side_nav.php"); ?>
- </nav>
- <div id="page-wrapper">
- <div class="container-fluid">
- <!-- Page Heading -->
- <div class="row">
- <div class="col-lg-12">
- <h1 class="page-header">
- Comments
- <!-- <small>Here are your comments</small> -->
- </h1>
- <a href="add_comment.php" class="btn btn-primary">Add comment</a>
- <div class="col-md-12">
- <table class="table table-hover">
- <thead>
- <tr>
- <th>Comment Id</th>
- <th>Photo</th>
- <th>Photo Id</th>
- <th>Author</th>
- <th>Body</th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($comments as $comment): ?> <!-- $comment is a row in the comments table -->
- <tr>
- <td><?php echo $comment->id; ?></td>
- <td><img class="user_small_image " src="<?php echo $SpecificPhoto->picture_path(); ?>"></td>
- <td><?php echo $SpecificPhoto->id; ?>
- <td><?php echo $comment->author; ?>
- <div class="action_links">
- <a href="delete_comment.php?id=<?php echo $comment->id; ?>&photo=<?php echo $SpecificPhoto->id ?>">Delete</a>
- </div>
- </td>
- <td><?php echo $comment->body; ?></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- </div><!-- end md-12-->
- </div>
- </div> <!--- row -->
- </div> <!-- container fluid-->
- </div> <!--end wrapper-->
- <?php include("includes/footer.php"); ?>
- /**********************************delete_comment.php******************************/
- <?php include("includes/init.php"); ?>
- <?php if (!$session->is_signed_in()) {redirect("login.php");} ?>
- <?php
- if (empty($_GET["id"])) {
- redirect("comments.php");
- }
- // create a new Comment and Photo object and then call the static function find_by_id (which is inherited)
- $comment= Comment::find_by_id($_GET["id"]);
- $photo_redirect = Photo::find_by_id($_GET["photo"]);
- if ($comment) {
- $comment->delete();
- redirect("comment_photo.php?id={$photo_redirect->id}");
- } else {
- redirect("comment_photo.php?id={$photo_redirect->id}");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement