I'm working with CodeIgniter to pull content from a column. The columns I can selecte from are named as "referred_user_1","referred_user_2","referred_user_3","referred_user_4","referred_user_5". Depending on the user's input, which is an integer ranging from 1-5, I'd like to specify the column. For example, if the user input "2", then I would like to pull data from column "referred_user_2"; if the user input "5", then column "referred_user_5".
Code:
$id=89343;
$referred_user_number=substr($this->encrypt->decode($code),-1); //depending on the user's input, $referred_user_number could be from number 1 to 5
$this->db->where('id', $id);
$query_email=$this->db->get('email_signup_refer_send')->row();
$referred_user = $query_email->'referred_user_.$referred_user_number'; //this is where I run into problem and error msg is shown as below
PHP error msg is: Parse error: syntax error, unexpected ''referred_user_.$referred_user' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) or variable (T_VARIABLE)
Advice is appreciated!