[eluser]runrun[/eluser]
Hi,
I am trying set default value for a select menu in the site's user profile section.
In detail, I need to load the date of birth of user to a select menu, this happens when user view their profile, and this profile is editable.
controller:
Code:
//get the date of birth of user from database
$username = $this->session->userdata('username');
$this->db->select(date)->from('user')->where('username',$username);
$query = $this->db->get();
$data['row'] = $query->row();
$data['Dchoices'] = array_merge(array('' => 'date'), range(1,31));
view:
Code:
<?php foreach($Rchoices as $Rkey=>$Rchoice):?>
<option value ="<?=$Rkey?>" <?=set_select('region', $Rkey, if($Rkey=$row->date){return TRUE;}else{return FALSE;})?>><?=$Rchoice?></option>
<?php endforeach; echo"\n";?>
I put the if condition in the third parameter of set_select. I get error "unexpected T_IF".