function hmgt_add_category() { global $wpdb; $model = $_REQUEST['model']; $array_var = array(); $data['category_name'] = $_REQUEST['medicine_cat_name']; if ($model == 'medicine') { $obj_medicine = new Hmgtmedicine(); $obj_medicine->hmgt_add_medicinecategory($data); $id = $wpdb->insert_id; } if ($model == 'department') { $user_object = new Hmgtuser(); $user_object->add_staff_department($data); $id = $wpdb->insert_id; } if ($model == 'bedtype') { $bed_type = new Hmgtbedmanage(); $bed_type->hmgt_add_bedtype($data); $id = $wpdb->insert_id; } if ($model == 'specialization') { $user_object = new Hmgtuser(); $user_object->add_doctor_specilize($data); $id = $wpdb->insert_id; } if ($model == 'operation') { $operation_type = new Hmgt_operation(); $operation_type->hmgt_add_operationtype($data); $id = $wpdb->insert_id; } if ($model == 'report_type') { $report_type = new Hmgt_dignosis(); $report_type->hmgt_add_report_type($data); $id = $wpdb->insert_id; } $row1 = '<tr id="cat-' . $id . '"><td>' . $_REQUEST['medicine_cat_name'] . '</td><td><a class="btn-delete-cat badge badge-delete" href="#" id=' . $id . '>X</a></td></tr>'; $option = "<option value='{$id}'>" . $_REQUEST['medicine_cat_name'] . "</option>"; $array_var[] = $row1; $array_var[] = $option; echo json_encode($array_var); die; }