Welcome Guest, Not a member yet? Register   Sign In
Arrays
#11

[eluser]Todlerone[/eluser]
I don't get the foreach loop error anymore but I have noticed that after I hit the form submit button it quickly displays array() and nothing gets added to my database table. I tried the
Code:
if (empty($ps->plans_plan_name) && $ps->plan_status_current == 'ip'){
but for some reason it doesn't seem to determine the NULL value...

I then tried to set a default value for the plans_plan_name field("not_set") and tried this
Code:
if ($ps->plans_plan_name == 'not_set' && $ps->plan_status_current == 'ip'){
But this also hasn't worked.
#12

[eluser]Todlerone[/eluser]
WOW this is really got me. Ok I tried the "pre" output before and after the form validation and....before it printsout as displayed earlier in this thread, after the form validation all I get is array().....

Code:
function add(){
        $data['user'] = $this->ion_auth->get_user_array();
        if (!$this->ion_auth->logged_in()){
                redirect('home/login', 'refresh');
            }else{
                $ptID = $this->session->userdata('demo_num_id');

            $this->load->helper(array('form', 'array'));
            $this->load->library('form_validation');
            $this->load->model('Patients_model');
            $this->load->model('Plans_cols');
            $this->config->load('patients');

            $data['status'] = $this->config->item('status');
            $data['tracking'] = $this->config->item('tracking_method');
            $data['method'] = $this->config->item('plan_method');
            $data['algorithm'] = $this->config->item('algorithm');
            $data['collimator'] = $this->config->item('collimator');
            $data['delivery'] = $this->config->item('delivery');

            $data['pt_status'] = $this->Patients_model->get_patient_status($ptID);
            $data['patient'] = $this->Patients_model->get_patient_where($ptID);
            $data['treatID'] = $this->uri->segment(4);
            $data['treatNUM'] = $this->uri->segment(5);
            $data['clinic_visit'] = $this->uri->segment(6);
            $plan_status = $this->Patients_model->get_status_where($ptID, $this->uri->segment(6));

            echo '<pre>'; print_r($plan_status); echo '</pre>';  //a
            $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
            if ($this->form_validation->run('plan_add') == FALSE){
                $this->title="Add a plan";    
                $this->thisPage="Patients";
                $this->load->view('header',$data);
                $this->load->view('patients/plan_add_form', $data);
                $this->load->view('sidebars/sidebar_patient_selected');
                $this->load->view('footer');
            }else{
                echo '<pre>'; print_r($plan_status); echo '</pre>';  //a

                    foreach ($plan_status as $ps):
                    if ($ps->plans_plan_name == "not_set" && $ps->plan_status_current == "ip"){
                        $this->Patients_model->update_plans_plan_name($ptID, $data['user']);
                        $this->Plans_cols->add_plans($ptID, $data['user']);
                        $this->Plans_cols->add_collimators($ptID, $data['user']);
                    }
                    if ($ps->plans_plan_name != $this->input->post('plans_plan_name')){
                        $this->Patients_model->add_new_cv_plan($ptID, $data['user']);
                        $this->Plans_cols->add_plans($ptID, $data['user']);
                        $this->Plans_cols->add_collimators($ptID, $data['user']);
                    }
                endforeach;
                //$this->Plans_cols->add_plans($ptID, $data['user']);
                //$this->Plans_cols->add_collimators($ptID, $data['user']);
                //redirect('patients/patient/patient_selected/', 'refresh');
            }// end form_validation
        }//end logged_in
    }// end plan_add




Theme © iAndrew 2016 - Forum software by © MyBB