當前位置:首頁 » 編程語言 » 評論功能php

評論功能php

發布時間: 2024-11-02 09:04:44

Ⅰ thinkphp 的文章評論回復功能怎麼做

文章下面給個輸入框
用戶輸入的評論保存在一個單獨的表,應該包括以下欄位:
評論者的id
評論的文章id
評論時間
評論內容
。。。。

Ⅱ php ajax jquery這三個要怎麼結合使用。

一個簡單的ajax+jquey評論功能,當然先要引用jquery-1.8.3.min.js

html代碼:

<formname="formcomment"id="formcomment"method="get">
評論:<textareaid="comment"name="comment"class="general"></textarea>
稱呼:<inputtype="text"id="name"name="name"class="general"/>
<inputtype="button"class="comment_btn"value="提交"/>
<spanclass="notice"></span>
</form>


js代碼

$(document).on("click",".comment_btn",function(){
varcomment=$("#comment");
varname=$("#name");
varnotice=$(".notice");
notice.html('');
if($.trim(comment.val())==''){
notice.html("請在評論里寫幾個字吧!");
returnfalse;
}else{
varurl="comment_ajax.php";//比如用www.cuangs.com/comment_ajax.php
varparams=$('#formcomment').serialize();
$.ajax({
url:url,
type:'post',
data:params,
dataType:'json',
success:function(data){
notice.html(data.notice);
}
});
}
});


comment_ajax.php代碼

$comment=$POST["comment"];
$name=$POST["name"];
if($comment){
$data=array(
"comment"=>$comment,
"name"=>$name,
"date"=>time()
);
//這里寫insert插入數據代碼
unset($data);
$data=array(
"notice"=>$temp->error==1?'評論失敗':'評論成功'
);
}else{
$data=array(
"notice"=>'評論失敗'
);
}
echojson_encode($data);

提交失敗和成功會有相應提示

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:336
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:378
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:612
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:32
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:107
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:944
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:741
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:803
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:511
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:372