function order() { // Order fields if (is_ajax()) { if (count($_POST) > 0 && $this->input->post('fields_table')) { $this->load->model('content_fields_model'); $table_order = $this->input->post('fields_table'); unset($table_order[0]); $table_order = array_values($table_order); $i = 1; foreach ($table_order as $id) { $Sort_fields = new Content_fields_model(); $Sort_fields->get_by_id($id); if ($Sort_fields->exists()) { $Sort_fields->sort = $i; $Sort_fields->save(); unset($Sort_fields); $i++; } } } return; } else { return show_404(); } }