Add integral function to php json_PHP tutorial

WBOY
Release: 2016-07-13 17:51:52
Original
1084 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

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])...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template