php - if loop to get data if present in table if not present then insert value in table and javascript to get the data on writing profile id -
i need if loop in view file , javascript when profile id entered should show related elements in form , i'm doing in codeignitor , part of view file
<tr> <td width='50%'> <table width="50%"><tr> <td width="50%"><strong>profile id </strong></td> <td width="50%"><input type="text" id="profile_id" name="profile_id" value="<?php echo $reg_personal_details->profile_id;?>"placeholder="employee id "/><?php echo form_error('profile_id');?><br></td> </tr> <tr> <td><strong>employee name </strong></td> <td><input type="text" id="profile_fname" name="profile_fname" value="<?php echo $reg_personal_details->profile_fname;?>"placeholder="employee name"/><?php echo form_error('profile_fname'); ?><br></td> </tr> <tr> <td><strong>employee type </strong></td> <td> <input type="text" id="profile_type" name="profile_type" value="<?php echo $reg_personal_details->profile_type;?>"placeholder="employee type"/><?php echo form_error('profile_type');?><br> </td> </tr> <tr>
here table: profile (profile_id, profile_fname, profile_lname, profile_email, profile_mobile, profile_type, profile_gender, profile_dob, profile_marital_status, profile_religion, profile_blood_group, profile_nationality, profile_iris, profile_biometric, profile_department, profile_designation, profile_project_designation, profile_image, address_1, address_2)
profile_id foreign key , primary key in other table emp_acc_id
model above :
public function reg_personal_details()
{ $reg_personal_details = array(
// need condition here read entered profile_id below data must store in id only// 'profile_type' => $this->input->post('profile_type'), 'profile_gender' => $this->input->post('profile_gender'), 'profile_dob' => $this->input->post('profile_dob'), 'profile_marital_status' => $this->input->post('profile_marital_status'), 'profile_religion' => $this->input->post('profile_religion'), 'profile_blood_group' => $this->input->post('profile_blood_group'), 'profile_nationality' => $this->input->post('profile_nationality'), 'profile_iris' => $this->input->post('profile_iris'), 'profile_biometric' => $this->input->post('profile_biometric'), 'profile_department' => $this->input->post('profile_department'), 'profile_designation' => $this->input->post('profile_designation'),
'profile_project_designation' => $this->input->post('profile_project_designation'), );
$this->db->update('profile',$reg_personal_details);
you should write java script check if particular element exists or not i.e if value not null generate new row tags dynamically , set value in response of query. generating tag dynamically can refer following page:-
http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/
Comments
Post a Comment