Welcome Guest, Not a member yet? Register   Sign In
form_dropdown
#1

[eluser]Kfrico[/eluser]
Code:
$options = array(
                  foreach($data->result() as $row){
                  $row->abc  => $row->abc ,  
                  }                                  
                );
  echo form_dropdown('JoinDate1', $options,'');

Why to appear a mistake

How to should write just good

Code:
echo form_dropdown('JoinDate1', foreach($data->result() as $row){$row} ,'');

Write like this also false

Is there better way
#2

[eluser]GSV Sleeper Service[/eluser]
Code:
foreach($data->result() as $row){
    $options[$row->abc] = $row->abc;
}                        
echo form_dropdown('JoinDate1', $options,'');

I'd recommend learning at least a little bit of PHP before diving into CodeIgniter...
#3

[eluser]got 2 doodle[/eluser]
controller
Code:
$this->load->model('program_data');
    $data ['themes'] = $this->program_data->get_theme_dropdown_array();

model
Code:
/*-----------------------------------------------------------------------*/                    
    function get_theme_dropdown_array() {
/*-----------------------------------------------------------------------*/
    /* get program by theme and count results */
    $themes_array = array();
    $themes_array[0] = 'Any';
    $query = $this->db->select('id, name');
    $query = $this->db->order_by("name");
    $query = $this->db->get('theme');
    if ($query->num_rows() > 0){
        foreach ($query->result() as $row)
                { $themes_array[$row->id] = $row->name.' ('.$this->get_program_count_by_theme($row->id).')';}
            }
    return $themes_array;
                    }

in view
Code:
<?php
echo form_label('Theme', 'ptheme');
echo form_dropdown('theme', $themes, 'Any');
echo form_submit('by_theme', 'GO');
?>

hope this helps
doodle




Theme © iAndrew 2016 - Forum software by © MyBB