ALTER TABLE dede_archives ADD zan int(11) NOT NULL DEFAULT '0' AFTER weight;
CREATE TABLE IF NOT EXISTS `dede_zan` ( `id` int(11) NOT NULL AUTO_INCREMENT, `aid` int(11) NOT NULL, `ip` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8
function zan($aid) { global $dsql; $row = $dsql->GetOne("Select id,zan From dede_archives where id='".$aid."'"); return $row['zan']; }
.zan p{ background:#000; opacity:.8;filter:alpha(opacity=80);} .zan p a{padding-left:30px; height:24px; background:url(/images/heart.png) no-repeat 4px -1px;color:#fff; font-weight:bold; font-size:14px} .zan p a:hover{background-position:4px -25px;text-decoration:none}
$(function(){ $("p a").click(function(){ var zan = $(this); var id = zan.attr("rel"); //对应id zan.fadeOut(300); //渐隐效果 $.ajax({ type:"POST", url:"/zan.php", data:"id="+id, cache:false, //不缓存此页面 success:function(data){ zan.html(data); zan.fadeIn(300); //渐显效果 } }); return false; }); });
{dede:field.id function="zan(@me)"/}
SetQuery("SELECt ip FROM dede_zan WHERe aid='".$id."' and ip='$ip'"); $dsql->Execute(); $count = $dsql->GetTotalRow(); if($count==0){ //如果没有记录 $dsql->ExecuteNoneQuery("update dede_archives set zan=zan+1 where id='$id'; ");//写入赞数 $dsql->ExecuteNoneQuery("insert into dede_zan (aid,ip) values ('$id','$ip'); ");//写入IP,及被赞的AID $rows = $dsql->GetOne("Select zan from dede_archives where id='".$id."'");//获取被赞的数量 $zan = $rows['zan']; //获取赞数值 echo $zan; }else{ echo "赞过了.."; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)