嫌麻煩的也可以:點擊下載
HTML:
給力 {OVOV:$answer_datas.goods/} 不給力 {OVOV:$answer_datas.bads/}
HTML對應的php檔案
$value){if($value['uid']==$uid){ $zan_lists[]=$value['answer_id'];}} $smarty->assign('zan_list',$zan_lists);//查詢當前登入的會員的uid對應的點贊的回答 /*****贊結束****/ /*****踩開始****/$cai_list = json_decode(str_replace("'",'"',$cai_json),true);$cai_lists=array();foreach($cai_list as $key=>$value){if($value['uid']==$uid){ $cai_lists[]=$value['answer_id'];}} $smarty->assign('cai_list',$cai_lists);//查詢當前登入的會員的uid對應的踩的回答 /*****踩結束****/$smarty->display('自己的靜態頁面');exit();break;}?>
ajax檔案:
ErrorMsg('檔案錯誤:shuzu/ovovsys_zan.php 不存在!');exit();}//將指定的數群組轉換成json資料,並且將雙引號轉換成單引號,不然放到數組檔案中後會出錯----4$zan_new_json = str_replace('"',"'",json_encode($zan_array));$fp = @fopen($config_path,'r+');if(!$content = @fread($fp,filesize($config_path))){$Base->ErrorMsg('無法讀取shuzu/ovovsys_zan.php檔案!');exit();}//執行替換,將數組檔案中對應的json資料----5$content = str_replace("\$zan_json = \"{$zan_json}\"","\$zan_json = \"{$zan_new_json}\"",$content);$fp = @fopen($config_path,'w+'); @fwrite($fp,$content); //修改對應的資料表中的資料----5$Db->ThisQuery("update `".$db_prefix."ask_answers` set `goods`=`goods`+1 where `ans_id`=".$user_answer['answer_id']."");exit();break; case 'cai'://踩(不給力)$cai_array = json_decode(str_replace("'",'"',$cai_json),true);$user_answer['uid']=$uid;$user_answer['answer_id']=$_POST['answer_id'];$cai_array[]=$user_answer;$config_path = 'shuzu/ovovsys_zan.php';if(!file_exists($config_path)){$Base->ErrorMsg('檔案錯誤:shuzu/ovovsys_zan.php 不存在!');exit();}$cai_new_json = str_replace('"',"'",json_encode($cai_array));$fp = @fopen($config_path,'r+');if(!$content = @fread($fp,filesize($config_path))){$Base->ErrorMsg('無法讀取shuzu/ovovsys_zan.php檔案!');exit();}$content = str_replace("\$cai_json = \"{$cai_json}\"","\$cai_json = \"{$cai_new_json}\"",$content);$fp = @fopen($config_path,'w+'); @fwrite($fp,$content); $Db->ThisQuery("update `".$db_prefix."ask_answers` set `bads`=`bads`-1 where `ans_id`=".$user_answer['answer_id']."");exit();break;}?>
對應的資料檔案(因為建立資料庫時沒有建立踩和贊的再斷,所以這裡就用php檔案存變數的方式儲存了一下答案對應的贊和踩的資料,其中包含使用者的id和答案的id)
你沒看錯,就是兩個變數
如果嫌複製著麻煩的話,也可以點擊下載壓縮檔,親,不要積分的喲!