Welcome Guest, Not a member yet? Register   Sign In
Dropdown shows Array Indexes
#1

[eluser]fildawg[/eluser]
Hi, I'm trying to fill a dropdown in a view from a DB. While this is working, the dropdown is showing the Array indexes of each value. I'm sure I'm overlooking something simple. Here's the code:

MODEL:
Code:
function Get_Promo_List()
    {
        $query = $this->db->select('code')->from('promotions')->get();
        return $query->result_array();
    }

CONTROLLER:
Code:
$this->load->model('Promotion_model');
        $data['promo_list'] = $this->Promotion_model->Get_Promo_List();
        $this->load->view('analytics_sel_promo', $data);

VIEW:
Code:
<?php
$this->load->helper('form');
echo form_open('analytics/get_data');
echo form_dropdown('Promotions', $promo_list, '');
echo form_submit('get_data', 'Use this promo');
echo form_close();

Any guidance would be greatly appreciated!

TIA!
#2

[eluser]flaky[/eluser]
this is how I solved this issue
Code:
public function get_dropdown(){
        $user_status_list;
        
        $this->db->select('user_status_id, user_status_name');
        $qr = $this->db->get($this->table);
        $qr = $qr->result_array();
        
        foreach($qr as $query)
            $user_status_list[$query['user_status_id']] = $query['user_status_name'];
        
        return $user_status_list;
    }
#3

[eluser]Kljofa[/eluser]
Just want to thank flaky.

I've had same problem with filling dropdown list with table data and its value, but your solution helped me.




Theme © iAndrew 2016 - Forum software by © MyBB