㈠ 求助,如何实现thinkphp官网的评论,回复 消息功能
只说说逻辑吧
只需要在设计数据表的时候比原来多增加两个字段就行,姑且叫 aid 和cid
aid用于记录是哪个文章下的评论,cid用于记录是哪条评论下的评论.
即 aid = 文章的ID cid = 被评论的这条评论的ID
当别人点击评论时 则只需要记录文章的ID 即aid 此时 cid = 0;
当别人在某条评论下回复时,则记录文章id 和这条评论的id 即cid = 等于此时评论的id
在显示的时候
//查询文章已TP5为例子
$pinglun=db::table('pinglun')->where('aid',id)->where('cid',0)->select();//查询一条文章的评论
foreach($pinglun1as$k=>$v){
$data[$k]=$v['neirong']//这里为评论的内容
$pinglun2=db::table('pinglun2')->where('cid',$v['id'])->select();
foreach($pinglun2as$kk=>$vv){
$data['huifu']=$vv['neirong']
}
}
纯手工 ,希望对你有帮助
㈡ php学出来能做什么
PHP学出来后,可以从事以下方面的工作和应用:
制作网站:
数据采集:
辅助开发:
开发框架和软件:
可从事的岗位: web前端工程师:虽然PHP主要是后端技术,但了解前端技术对于全栈开发非常有帮助。 PHP后端开发:专注于PHP后端逻辑的开发和维护。 PHP技术开发工程师:负责PHP技术的应用和开发,包括框架搭建、模块开发等。 PHP程序员:编写PHP代码,实现业务逻辑和功能需求。 PHP架构师:负责PHP应用的架构设计和技术选型,确保系统的稳定性和可扩展性。
综上所述,PHP学出来后有着广泛的应用领域和就业前景,可以根据个人兴趣和职业规划选择合适的岗位和方向。
㈢ 【新手求助】PHP点赞功能,急!!!
html:
<head>
<scriptsrc="common/js/jquery.js"type="text/javascript"></script>
<scriptlanguage="JavaScript"type="text/javascript">
jQuery(function($){
//这两个是鼠标放上去的效果
$(".zhan").hover(function(){
$(this).children("b").toggle();
});
$(".cai").hover(function(){
$(this).children("b").toggle();
});
});
</script>
<scripttype="text/javascript">
<!--这两个点击事件可以改进的,因为事件问题,所以就弄了两个点击事件
$(document).ready(function(e){
//点赞(给力)
$('.zhan').click(function(){
varzhan=$(this);
varleft=parseInt($(this).offset().left)+10,top=parseInt($(this).offset().top)-10,obj=$(this);
$(this).append('<divid="zhan"><b>+1</b></div>');
$('#zhan').css({'position':'absolute','z-index':'1','color':'#C30','left':left+'px','top':top+'px'}).animate({top:top-10,left:left+10},'slow',function(){
$(this).fadeIn('fast').remove();
varNum=parseInt(obj.find('span').text());
Num++;
obj.find('span').text(Num);
});
$.ajax({
url:"ajax.php?action=zan",
type:"post",
data:"answer_id="+$(this).attr("alt"),
success:function(datas){
zhan.unbind('click');
zhan.parent().parent().siblings().children().children().unbind('click');
zhan.parent().parent().siblings().children().children().attr("class","evaluate-inner");
zhan.attr("class","evaluate-inner");
}
});
});
//踩(不给力)
$('.cai').click(function(){
varcai=$(this);
varleft=parseInt($(this).offset().left)+10,top=parseInt($(this).offset().top)-10,obj=$(this);
$(this).append('<divid="cai"><b>-1</b></div>');
$('#cai').css({'position':'absolute','z-index':'1','color':'#7DAAD5','left':left+'px','top':top+'px'}).animate({top:top-10,left:left+10},'slow',function(){
$(this).fadeIn('fast').remove();
varNum=parseInt(obj.find('span').text());
Num--;
obj.find('span').text(Num);
});
$.ajax({
url:"ajax.php?action=cai",
type:"post",
data:"answer_id="+$(this).attr("alt"),
success:function(datas){
cai.unbind('click');
cai.parent().parent().siblings().children().children().unbind('click');
cai.parent().parent().siblings().children().children().attr("class","evaluate-inner");
cai.attr("class","evaluate-inner");
}
});
});
});
//-->
</script>
</head>
<body>
<!--给力开始-->
<spandata-evaluate="0"id="evaluate-1908165795"class="evaluate"alog-action="qb-zan-btn"><spanclass="evaluate-outer">
<!-----判断对应的回答的id是否在自己创建的存储赞和踩数据的php文件,如果赞或者踩存在一个的话就不能再单击---->
<spanclass="evaluate-inner{if$answer_datas.ans_id|in_array:$zan_listor$answer_datas.ans_id|in_array:$cai_list/}{else/}zhan{/if/}"alt="{$answer_datas.ans_id/}"><bstyle="display:none"class="evaluate-tipevaluate-num-fixed">给力</b><bclass="evaluate-numevaluate-num-fixed"><span>{$answer_datas.goods/}</span></b></span></span></span>
<!--不给力开始-->
<spandata-evaluate="0"id="evaluate-bad-1908165795"class="evaluateevaluate-bad"alog-action="qb-evaluate-outer"><spanclass="evaluate-outer"><spanclass="evaluate-inner{if$answer_datas.ans_id|in_array:$zan_listor$answer_datas.ans_id|in_array:$cai_list/}{else/}cai{/if/}"alt="{$answer_datas.ans_id/}"><bstyle="display:none;"class="evaluate-tipevaluate-num-fixed">不给力</b><bclass="evaluate-numevaluate-num-fixed"style="display:inline-block;"><span>{$answer_datas.bads/}</span></b></span></span></span>
</div>
</div>
<!--评论回答开始-->
</body>
</html>
php
<?php
$action=$_GET['action'];//获取get方式传过来的action
require_once("array/ovovsys_zan.php");
switch($action){
case'detail':
/*****赞开始****/
$zan_list=json_decode(str_replace("'",'"',$zan_json),true);
$zan_lists=array();
foreach($zan_listas$key=>$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_listas$key=>$value){
if($value['uid']==$uid){
$cai_lists[]=$value['answer_id'];
}
}
$smarty->assign('cai_list',$cai_lists);//查询当前登录的会员的uid对应的踩的回答
/*****踩结束****/
$smarty->display('自己的静态页面');
exit();
break;
}
?>
ajax
<?php
require_once("array/ovovsys_zan.php");//这里引用array文件夹中的数组文件
$action=trim($_GET['action']);
if(empty($action)){
echo'<fontcolor=red>参数错误!</font>';exit();
}
switch($action){
case'zan'://点赞(给力)
//$zan_json是数组文件中设置的数组变量,存的是json数据----1
$zan_array=json_decode(str_replace("'",'"',$zan_json),true);
//获取当前的会员的uid-----2
$user_answer['uid']=$uid;
//获取对应的赞的回答的id----2
$user_answer['answer_id']=$_POST['answer_id'];
//将会员的uid和答案的id一块的数组放到指定的数组中----3
$zan_array[]=$user_answer;
$config_path='shuzu/ovovsys_zan.php';
if(!file_exists($config_path)){
$Base->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`+1where`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`-1where`ans_id`=".$user_answer['answer_id']."");
exit();
break;
}
?>
对应的数据文件(因为创建数据库时没有创建踩和赞的再断,所以这里就用php文件存变量的方式保存了一下答案对应的赞和踩的数据,其中包含用户的id和答案的id):
<?php
$zan_json="";
$cai_json="";
?>
你没看错,就是两个变量
㈣ FancyCaptcha使用方法
要使用FancyCaptcha插件,首先,请确保将插件文件上传到服务器的/usr/plugins/目录中。登录到你的网站后台,找到插件管理功能,启用FancyCaptcha插件。接下来,按照插件提供的设置指南,进行必要的配置,比如验证码的样式、字符类型等。
完成基础设置后,你需要在模板文件中添加FancyCaptcha。通常,评论功能区域的表单(comments的form标签)是插入代码的理想位置。在form标签之间,找到你认为适合插入验证码的地方,插入以下PHP代码:
这段代码会显示动态生成的验证码图片,以增强你的网站评论系统的安全性。确保保存并更新模板后,访问你的网站,新的验证码功能就应该开始生效了。如果遇到任何问题,可以查阅插件的文档或联系插件开发者寻求帮助。