Home > php教程 > php手册 > php json增加积分函数

php json增加积分函数

WBOY
Release: 2016-06-13 10:50:18
Original
1119 people have browsed it

[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
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template