當前位置:首頁 » 編程語言 » 評論功能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-03-17 13:36:59 瀏覽:438
三星手機簡訊在那個文件夾 發布:2025-03-17 13:31:51 瀏覽:194
安卓皇帝隱藏劇情在哪裡 發布:2025-03-17 13:18:53 瀏覽:507
新版安卓為什麼不兼容 發布:2025-03-17 13:18:49 瀏覽:483
s3哪個配置性價比高 發布:2025-03-17 13:06:09 瀏覽:320
氣體壓縮能量 發布:2025-03-17 13:00:16 瀏覽:78
壓縮油19 發布:2025-03-17 12:25:29 瀏覽:858
linux上網代理 發布:2025-03-17 12:23:56 瀏覽:361
c是高級語言嗎 發布:2025-03-17 12:16:31 瀏覽:525
python泛型 發布:2025-03-17 12:15:01 瀏覽:484