at first value is exist in database in codegniter, select value and count row using num_rows(). and check if value is exist then update the table value or if value is not exist then insert a new record into the database. For example:
public function CheckValueInModal($data,$id){ $sql=$this->db->where('user_id',$id)->get('admin_signup'); $cou=$sql->num_rows(); if($cou==1){ $this->db->update('Table Name',$data); redirect("page location"); } else{ $couq=$this->db->insert('Table Name',$data); redirect("page location"); } }
You can try this code in your web application.
Question and answer is powered by AnsPress.io