Fetching data from db and displaying to ddl using codeigniter
I am getting the following error on CodeIgniter
.
PHP Error Occurred Severity: Notification Message: Undefined variable: assign_to Filename: admin / insert.php Line Number: 20
PHP error occured Severity: Warning Message: Invalid argument supplied by foreach () Filename: admin / insert.php Line number: 20 "
On my controller page
<?
$data['assigned_to'] = $this->user_model->get_ddl();
var_dump($data['assigned_to']);
?>
Model page:
public function get_ddl()
{
$this-> db ->select('user_name');
$this-> db ->from('user');
$query = $this->db->get();
return $query->result_array();
}
Page view:
<tr><td>Assigned To </td><td><select name='ddl_uname'>
<?
foreach($assigned_to as $row)
{
echo '<option value="'.$row->user_name.'">'.$row->user_name.'</option>';
}?>
</select></td></tr>
+3
source to share
1 answer