Skip to main content

ambil nilai dari dropdown

May 26, 2011 by handi2009

handi2009's picture

gan, sorry ane minta tolong...

ane mau ambil data dari dropdown, tp error:

Fatal error: Call to a member function get_opt_thn() on a non-object in C:\wamp\www\sipapbd\application\modules\auth\controllers\auth.php on line 24

//controller

class Auth extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Login_model');
}
function index()
{
$this->login_model->get_opt_thn();

$data['']= 'login_view';
show($data[''],$data);
}

//model
..
function get_thn()
{
$q =
'select (year from current_timestamp) as "TAHUN"
union all
select
(year from STATUS_ANGGARAN."STATUS")
from "TAHUN_ANGGARAN" STATUS_ANGGARAN
where STATUS_ANGGARAN."TANGGAL_PENERIMAAN") ORDER BY "TAHUN"' ;

$return = $this->db->query($q);
return $return;
}

function get_opt_thn()
{
$return = array(''=>'Pilih');

$result = $this->get_thn();

if($result->num_rows()>0)
{
foreach($result->result() as $row)
{
$return[$row->TAHUN]=$row->TAHUN;
}
}
return $return;
}

//view
...

 echo form_dropdown('TAHUN',$opt_tahun);

makasih gan, CI-id.com sukses sllalu :)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Agak kesulitan untuk membantu

May 29, 2011 by cahndeso, 11 hours 40 min ago
Comment: 8253

cahndeso's picture

Agak kesulitan untuk membantu brad... sebab... bagian baris mana yang ke 24...? dicontoh controller brad tidak sampai baris ke 24... jika itu bagian dari program yang sengaja dipotong, ketikkan barisnya... sehingga teman-teman tahu baris ke 24 yang mana....

Happy Coding...

Cahndeso...

Premium Drupal Themes by Adaptivethemes