当前位置:Gxlcms > PHP教程 > phpjson增加积分函数_PHP教程

phpjson增加积分函数_PHP教程

时间:2021-07-01 10:21:17 帮助过:17人阅读

[html]
function zeng_integral(){
$jifen=& m('integral');
/*判断网吧*/
$store=isset($store_id)?intval($store_id):0;
$injifen=$jifen->get(array('user_id'=>$_SESSION['user_info']['user_id']));
$yanzhen=json_decode($injifen['integrallog'],true);

if(isset($injifen)){
$arrstore=array();
foreach ($yanzhen as $k=>$v){
$arrstore[]=$v['store_id'];
}
/*判断网吧积分是否存在如果存*/
if (in_array($store,$arrstore)) {
foreach ($yanzhen as $key=>$val){
$yanzhen[$key]['store_id']=$key;
$yanzhen[$key]['jifen']=$val['jifen']+5;
}
$integral=json_encode($yanzhen);
}else {
foreach ($yanzhen as $key=>$val){
$yanzhen[$store]['store_id']=$store;
$yanzhen[$store]['jifen']=1;
}
$integral=json_encode($yanzhen);
}
/*构造数据*/
$data=array(
'integrallog'=>$integral,
);
$integ=$jifen->edit($injifen['id'],$data);
if ($integ) {
return true;
}
}else {
/*构造数组*/
$config=array();
$config[$store]['store_id']=$store;
$config[$store]['jifen']=1;
$integral=json_encode($config);
/*构造数据*/
$data=array(
'user_id'=>$_SESSION['user_info']['user_id'],
'integrallog'=>$integral,
);
$integ=$jifen->add($data);
if ($integ) {
return true;
}
}

}
function zeng_integral(){
$jifen=& m('integral');
/*判断网吧*/
$store=isset($store_id)?intval($store_id):0;
$injifen=$jifen->get(array('user_id'=>$_SESSION['user_info']['user_id']));
$yanzhen=json_decode($injifen['integrallog'],true);

if(isset($injifen)){
$arrstore=array();
foreach ($yanzhen as $k=>$v){
$arrstore[]=$v['store_id'];
}
/*判断网吧积分是否存在如果存*/
if (in_array($store,$arrstore)) {
foreach ($yanzhen as $key=>$val){
$yanzhen[$key]['store_id']=$key;
$yanzhen[$key]['jifen']=$val['jifen']+5;
}
$integral=json_encode($yanzhen);
}else {
foreach ($yanzhen as $key=>$val){
$yanzhen[$store]['store_id']=$store;
$yanzhen[$store]['jifen']=1;
}
$integral=json_encode($yanzhen);
}
/*构造数据*/
$data=array(
'integrallog'=>$integral,
);
$integ=$jifen->edit($injifen['id'],$data);
if ($integ) {
return true;
} www.2cto.com
}else {
/*构造数组*/
$config=array();
$config[$store]['store_id']=$store;
$config[$store]['jifen']=1;
$integral=json_encode($config);
/*构造数据*/
$data=array(
'user_id'=>$_SESSION['user_info']['user_id'],
'integrallog'=>$integral,
);
$integ=$jifen->add($data);
if ($integ) {
return true;
}
}

}


作者:chaojie2009

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478155.htmlTechArticle[html] function zeng_integral(){ $jifen= m(integral); /*判断网吧*/ $store=isset($store_id)?intval($store_id):0; $injifen=$jifen-get(array(user_id=$_SESSION[user_info][user_id])...

人气教程排行