function display_suggestion($suggestion_row) { $database = DB::getInstance(); $db = $database->getConnection(); //lets determine, if this user has already voted on this: $mysql['user_id'] = $db->real_escape_string($_SESSION['user_id']); $mysql['suggestion_id'] = $db->real_escape_string($suggestion_row['suggestion_id']); $votes_sql = "SELECT * FROM suggestion_votes WHERE user_id='" . $mysql['user_id'] . "' AND suggestion_id='" . $mysql['suggestion_id'] . "'"; $votes_result = _mysqli_query($votes_sql); //($votes_sql); $already_voted = ''; if ($votes_result->num_rows > 0) { $already_voted = '1'; } if ($suggestion_row['votes'] > 0) { $suggestion_row['votes'] = '+' . $suggestion_row['votes']; } $mysql['user_id'] = $db->real_escape_string($suggestion_row['user_id']); $user_sql = "SELECT user_username FROM users WHERE user_id='" . $mysql['user_id'] . "'"; $user_result = _mysqli_query($user_sql); //($user_sql); $user_row = $user_result->fetch_assoc(); $html['suggestion_id'] = htmlentities($suggestion_row['suggestion_id'], ENT_QUOTES, 'UTF-8'); $html['user_username'] = htmlentities($user_row['user_username'], ENT_QUOTES, 'UTF-8'); $html['suggestion_time'] = date('M d, Y', $suggestion_row['suggestion_time']); $html['suggestion_votes'] = htmlentities($suggestion_row['suggestion_votes'], ENT_QUOTES, 'UTF-8'); $html['suggestion_text'] = htmlentities($suggestion_row['suggestion_text'], ENT_QUOTES, 'UTF-8'); ?> <li id="c-comment<?php echo $html['suggestion_id']; ?> "> <table class="c-table" cellspacing="0" cellpadding="0"> <tr class="c-head"> <td class="c-info"><strong><?php echo $html['user_username']; ?> </strong> <span class="c-time"><?php echo $html['suggestion_time']; ?> </span></td> <td class="c-votes" id="c-votes<?php echo $html['suggestion_id']; ?> "><?php echo $html['suggestion_votes']; ?> rating</td> <td class="c-vote-no"> <img id="c-vote-no<?php echo $html['suggestion_id']; ?> " src="/202-img/icons/18x18/vote-no<?php if ($already_voted == '1') { echo '-off'; } ?> .png" alt="Vote No" title="Vote No" <?php if ($already_voted != '1') { ?> onclick="vote('<?php echo $html['suggestion_id']; ?> ','','1');" <?php } ?> /> </td> <td class="c-vote-yes"> <img id="c-vote-yes<?php echo $html['suggestion_id']; ?> " src="/202-img/icons/18x18/vote-yes<?php if ($already_voted == '1') { echo '-off'; } ?> .png" alt="Vote Yes" title="Vote Yes" <?php if ($already_voted != '1') { ?> onclick="vote('<?php echo $html['suggestion_id']; ?> ','1','');" <?php } ?> /> </td> <?php if (AUTH::admin_logged_in() == true) { ?> <td class="c-delete"> <img id="c-delete<?php echo $html['suggestion_id']; ?> " src="/202-img/icons/16x16/cancel.png" title="Delete" onclick="deleteComment('<?php echo $html['suggestion_id']; ?> ');"/> </td> <td class="c-complete"> <img id="c-complete<?php echo $html['suggestion_id']; ?> " src="/202-img/icons/16x16/accept.png" title="Completed" onclick="completeComment('<?php echo $html['suggestion_id']; ?> ');"/> </td> <?php } ?> </tr> </table> <div class="c-body"> <?php echo $html['suggestion_text']; ?> <div style="text-align: right;"><?php //show on show comments, if there are comments $comments = 0; $comments = numberofcomments($suggestion_row['suggestion_id']); if ($comments['from'] != '') { ?> <a class="onclick_color c-onclick" id="c-showComments<?php echo $html['suggestion_id']; ?> " onclick="showComments('<?php echo $html['suggestion_id']; ?> ');">[Show Comments <?php echo $comments['from'] . ' of ' . $comments['to']; ?> ]</a> <a class="onclick_color c-onclick" id="c-hideComments<?php echo $html['suggestion_id']; ?> " onclick="hideComments('<?php echo $html['suggestion_id']; ?> ');" style="display: none;">[Hide Comments]</a> <?php } ?> <a class="onclick_color c-onclick" id="c-showReply<?php echo $html['suggestion_id']; ?> " onclick="showCreply('<?php echo $html['suggestion_id']; ?> ');">[Reply]</a> <a class="onclick_color c-onclick" id="c-hideReply<?php echo $html['suggestion_id']; ?> " onclick="hideCreply('<?php echo $html['suggestion_id']; ?> ');" style="display: none;">[Hide Reply]</a> </div> </div> <div id="c-row2<?php echo $html['suggestion_id']; ?> " class="c-row2"> <div id="c-post<?php echo $html['suggestion_id']; ?> " style="display: none;"> <div id="c-options<?php echo $html['suggestion_id']; ?> " class="c-highlight"> [Reply] </div> <div id="c-reply<?php echo $html['suggestion_id']; ?> " class="c-reply"> <form id="c-reply-form<?php echo $html['suggestion_id']; ?> " onsubmit="return suggestionReply('<?php echo $html['suggestion_id']; ?> ');" method="post"> <input type="hidden" name="suggestion_reply_to_id" value="<?php echo $html['suggestion_id']; ?> "/> <textarea name="c-suggestion" id="c-suggestion<?php echo $html['suggestion_id']; ?> " class="c-reply-textarea"></textarea> <div id="c-error<?php echo $html['suggestion_id']; ?> " class="error" style="display: none;">The submission you sent us was empty!</div> <input type="submit" value="Submit Comment" class="c-reply-submit"/> </form> </div> </div> <div id="c-replies<?php echo $html['suggestion_id']; ?> " style="display: none;"> <?php if ($comments > 0) { ?> <div class="comment2"> <ul> <li> <?php $mysql['suggestion_id'] = $db->real_escape_string($suggestion_row['suggestion_id']); $suggestion2_sql = "SELECT * FROM suggestions WHERE suggestion_reply_to_id='" . $mysql['suggestion_id'] . "'"; $suggestion2_result = _mysqli_query($suggestion2_sql); //($suggestion2_sql); while ($suggestion2_row = $suggestion2_result->fetch_array()) { display_suggestion($suggestion2_row); } ?> </li> </ul> </div> <?php } ?> </div> </div> </li> <?php }