Welcome Guest, Not a member yet? Register   Sign In
Need help for an rookie
#2

LaPouleLustucru thank you very much , it's perfect! you allowed me to make good progress .

I forgot to mention in my first post but I want to add a condition.

I hope that if the value of $user_id exists in " from_user_id " , the value of $nb_kiff will be updated in "nb_kiff" , otherwise insert .

I tried different methods but I can not write my code correctly .

If I try : if $ user_id > 0 , it does not. Can you help me to complete my code please .

Here's what I try to do :

PHP Code:
public function count_add_kiff($user_id
   
    $this
->db->where('from_user_id'$user_id);
 
   $this->db->from('user_love');
 
   
    
if ($user_id 0) {//*Vérify if exist
 
   
    $nb_kiff 
$this->db->count_all_results();  
    
    $data 
= array( 
 
       'from_user_id' => $user_id,
 
       'nb_kiff' => $nb_kiff
    
);
 
   $this->db->update('score'$data);
 
           
    return $nb_kiff
;
    }
    else
    {
        
$nb_kiff $this->db->count_all_results();
 
   
    $data 
= array( 
 
       'from_user_id' => $user_id,
 
       'nb_kiff' => $nb_kiff
    
);
 
   $this->db->insert('score'$data);
 
           
    return $nb_kiff
;



Thank you in advance

Violette
Reply


Messages In This Thread
Need help for an rookie - by Violette - 11-28-2015, 07:01 AM
RE: Need help for an rookie - by Violette - 11-29-2015, 10:38 PM
RE: Need help for an rookie - by Violette - 11-30-2015, 02:48 AM
RE: Need help for an rookie - by Violette - 11-30-2015, 05:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB