[eluser]hrg.vincent[/eluser]
Hi all, please help to check, anything wrong from my code in below. I'm using ODBC connection but fails to get data into dropdownlist.
I keep getting error "Undefined variable: company_list". I trying mysql and it's work. So I thinking that is something wrong from the ODBC code.
Code:
// Controller
public function getCompanyData()
{
$this->load->model('Company_m');
$data['company_list'] = $this->Company_m->getCompany();
}
Code:
// Model -->Company_m
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->GEMINI = @odbc_connect(MY_DATABASE_HOST, MY_DATABASE_NAME, MY_DATABASE_PSWD);
}
function getCompany()
{
$sql = "SELECT company_id, company_name FROM dev.company";
$result = odbc_exec($this->GEMINI,$sql);
if (odbc_fetch_row($result))
{
foreach($result->result_array() as $row) {
$return[$row['company_id']] = $row['company_name'];
}
}
return $return;
}
Code:
// View
<?php echo form_dropdown('company_list', $company_list); ?>