2017-02-13 27 views
1

好傢伙, 我'新在PHP中加入一些新的東西,我需要幫助如何添加簡單的編輯對我的評論框

添加簡單的編輯爲我添加評論框?

謝謝我希望我能在這裏得到幫助。 謝謝我希望我能在這裏得到幫助。

這樣 enter image description here

<!-- Start Add Comment --> 
<?php 
if (isset($_SESSION['user'])) { 
    $stopitem = $con->prepare("SELECT opitem FROM items"); 
    // Execute The Statement 
    $stopitem->execute(); 
    // Assign To Variable 
    $opitem = $stopitem->fetch(); 
    if ($opitem['opitem'] == 0) { 
     ?> 
     <div class="row"> 
      <div class="col-md-offset-1"> 
       <div class="add-comment"> 
        <h3> 
         Add Your Comment 
        </h3> 
        <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] . '?itemid=' . $item['Item_ID'] ?>"> 
         <textarea name="comment" required="required"></textarea> 
         <input class="btn btn-primary" type="submit" value="Add Comment" name=""> 
        </form> 
        <?PHP 
        if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
         $comment = filter_var($_POST['comment'], FILTER_SANITIZE_STRING); 
         $userid = $item['Member_ID']; 
         $itemid = $item['Item_ID']; 
         if (!empty($comment)) { 
          $stmt = $con->prepare("INSERT INTO comments(comment, status, comment_date, item_id, user_id) VALUE(:zcomment, 0, NOW(), :zitemid, :zuserid)"); 
          $stmt->execute(array(
           'zcomment' => $comment, 
           'zitemid' => $itemid, 
           'zuserid' => $userid 
          )); 
          if ($stmt) { 
           echo "Comment Added"; 
          } 
         } else { 
          echo '<div class="alert alert-danger">You Must Add Comment</div>'; 
          echo '<script language="javascript">'; 
          echo 'alert("You Must Add Comment")'; 
          echo '</script>'; 
         } 
        } 
         ?> 
       </div> 
      </div> 
     </div> 
     <?php 
    } else { 
     echo "This Item is closed."; 
    } 
} else { 
    echo '<a href="login.php">Regester</a> or <a href="login.php">Log In</a> To Add Comment'; 
} 
?> 
<!-- End Add Comment --> 
+0

可以使用CKEditor的http://ckeditor.com/ –

+0

請選擇答案,因爲接受,如果它是對您有所幫助。 –

+0

如何在評論框中安裝? –

回答

1

只需添加到你的頭一節。

<script src="http://cloud.tinymce.com/stable/tinymce.min.js"></script> 
    <script>tinymce.init({ selector:'textarea' });</script> 
+0

當我按下按鈕添加評論沒有作用?我該怎麼辦 ? –

+1

是的,它是完全免費的。 –

+1

試試這個。 –