I'm using codeigniter and trying to write a Helper class for loading dropdown dynamicly according to model name and the attribute which is the Column name for view.
function dropdown($Class,$Attribute)
{
$Output=NULL;
define("CLASSNAME", $Class."_model");
define("ATTRIBUTE", $Attribute);
$CI = get_Instance();
$CI->load->model(CLASSNAME);
$FullData=$CI->CLASSNAME->get();
foreach ($FullData as $Data)
{
$Output.='<option value="'.$Data->Id.'">'.$Data->ATTRIBUTE.'</option>';
}
return $Output;
}
But when I call it means i am getting this error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: News::$CLASSNAME
Filename: helpers/component_helper.php
Line Number: 11
Fatal error: Call to a member function get() on a non-object in C:\xampp\test\application\helpers\component_helper.php on line 11