I'm trying to put a dynamic title on my website so here it is.
class Survey extends MY_Controller {
public $my_title;
public function __construct(){
parent::__construct();
$this->load->model('Survey_model');
$this->my_title = ""; //setting to blank
}
public function survey_form(){
$this->data['title'] = $this->my_title; //display the title
$this->middle = 'Survey_view';
$this->layout();
}
public function validate_stub($survey_code){
$data = $this->Survey_model->get_questions($survey_code);
$this->my_title = $this->Survey_model->get_quest_title($survey_code); //getting from database title
$this->session->set_userdata('stub_data', $data);
redirect('Survey/survey_form');
}
}
The first to trigger is the validate_stub function then i would like to pass the return of get_quest_title to global variable $my_title then pass it to the survey_form function. In this case $this->my_title is blank, how can i pass the title from db then put into the global variable then pass to the view. Thanks