public function countUserComments() { $userComments = GuestBook::getUserComments($this); if (is_array($userComments)) { $this->totalComments = count($userComments); } else { $this->totalComments = 0; } }
<!-- Edit Modal --> <div id="edit" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="text-center modal-title">Edit Comment in GuestBook</h4> </div> <div class="modal-body"> <form method="POST" class="form-horizontal" role="form" action="controller/redirect.php"> <div class="form-group"> <?php $userComments = GuestBook::getUserComments($user); if (is_array($userComments)) { // The value of 'userComment' will be the comment ID echo '<select id="editSelect" class="form-control" name="userComment" onchange="verifySelection(this)">'; echo '<option value="">--- SELECT A COMMENT ---</option>'; for ($i = 0; $i < count($userComments); ++$i) { // If ADMIN is logged in, store the username for their listing of comments $username = isset($_SESSION['adminLoggedIn']) ? $userComments[$i]['user_Username'] . ' | ' : ''; echo '<option value="' . $userComments[$i]['comm_ID'] . '">' . $userComments[$i]['comm_Title'] . ' | ' . $username . date("F j, Y, g:i a", $userComments[$i]['comm_Date_Posted']) . '</option>'; } echo '</select>'; ?> <!-- Show the button to allow edit functionality --> <br/> <div class="text-center form-group"> <button type="submit" class="btn btn-primary" name="edit" id="editButton" disabled>Edit Comment</button>