<?php if (ImgIsMine($img["id"], $bdd)) { // Si la photo appartient au user logué ?> <a href="../deleteImg.php?var<?php echo $img['id']; ?> ">DEL</a> <?php } ?> </div> <div class="commentaire"> <!-- DIV POUR LES COMMENTAIRES --> <div class="afficheCom"> <?php displayComment($bdd, $img['id']); ?> </div> <form class="discom" action="../add_comment.php?var=<?php echo $img['id']; ?> " method="POST"> <div class="commentaire_zone"> <input type="textarea" name="comment"> </div> <div class="commentaire_bouton"> <input type="submit" class="bouton_com" value="OK"> </div> </form> </div>
} } } } //выводит текстовое поле для написания коммента function displayEditor() { // форма для написания коммента echo '<form action="7.php" method="GET">'; echo '<textarea name="comment" rows="10" cols="55">' . '</textarea>'; echo '</br>'; echo '<input type="submit" value="отправить комментарий">'; echo '</form>'; } //считываем все комментраии из файла $commentsStack = file('7.txt'); $seporator = '[endOfComment]'; //проверяем, был ли введен коментарий if ($_GET) { $formatedComment = $_GET['comment'] . $seporator; array_push($commentsStack, $formatedComment); //после того как поместили комент - очищаем GET в адресной строке header('Location: http://localhost:8080/homeworks/functions_forms_tasks/7.php'); $f = fopen('7.txt', 'a+'); fwrite($f, $formatedComment); displayComment($commentsStack); displayEditor(); } else { displayComment($commentsStack); displayEditor(); }
<li class="tab"><a onclick="playSound('<?php echo SOUND_CLICK; ?> ')" href="#four">Broadcasts</a></li> </ul> </div> <div id="one"> <div style="clear:both"></div> <?php arsort($allNotifications); $count = 0; foreach ($allNotifications as $key => $notification) { if (substr($key, 0, 3) == 'cmt') { displayComment(substr($key, -1, 1)); } elseif (substr($key, 0, 3) == 'btl') { displayBattle(substr($key, -1, 1)); } elseif (substr($key, 0, 3) == 'brd') { displayBroadcast(substr($key, -1, 1)); } $count++; if ($count == NUM_RECORDS) { break; } } ?> </div> <div id="two" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> <?php echo $result_html;
function getRootComments($conn, $product_id, $reply_number) { $stmt = $conn->prepare("SELECT ProductComments.comment_text, ProductComments.comment_id, Customers.customer_fname, Customers.customer_lname\n FROM shopdb.ProductComments, shopdb.Customers\n WHERE ProductComments.product_id = ? AND ProductComments.customer_id = Customers.customer_id AND ProductComments.comment_parent_id IS NULL;"); $stmt->bind_param("i", $product_id); $stmt->execute(); $stmt->bind_result($comment_text, $comment_id, $comment_fname, $comment_lname); $stmt->store_result(); //Loops until there are no more comments with the same parent while ($stmt->fetch()) { //display the comment displayComment($comment_text, $comment_fname, $comment_lname, $reply_number, $comment_id); //retrieve any replies to this comment getReply($conn, $comment_id, $reply_number + 1); } $stmt->free_result(); $stmt->close(); }