Welcome Guest, Not a member yet? Register   Sign In
Drop-down with option group
#11

[eluser]mdcode[/eluser]
After trying multiple ways of doing this, and attempting to use your advice bretticus of attempting to "array_combine" the two results so I can use them in the form, I don't think it's going to work this way since the value keys must be the id of the subtype row.

I have done some reworking of the database (to follow along more with CI recommendations) and code (as per recommendations from another user in another thread), and this is how it stands right now:

MODEL:
Code:
/* get all substrates */
            function get_all_substrates()
            {
                $this->db->select('*');
                $this->db->from('subtypes');
                $this->db->order_by('ssid', 'subtype');
                
                $query = $this->db->get();
                
                $this->db->select('*');
                $this->db->from('substrates');
                $this->db->order_by('substrate');
                
                $query2 = $this->db->get();
                return ($query->num_rows) ? $query->result_array() : FALSE;
                return ($query2->num_rows) ? $query2->result_array() : FALSE;
            }

CONTROLLER:
Code:
/* grab the substrates list */
            if ($substrates = $this->projects_model->get_all_substrates())
            {
                foreach ($substrates as $key=>$value)
                $data['substrates'][$value['id']] = $value['subtype'];
            }

And VIEW:
Code:
<?php echo form_dropdown('substrate', $substrates, '', $dds); ?>

I just cannot get the two results into the dropdown...
#12

[eluser]bretticus[/eluser]
[quote author="mdcode" date="1237972067"]
Code:
return ($query->num_rows) ? $query->result_array() : FALSE;
                return ($query2->num_rows) ? $query2->result_array() : FALSE;
            }

I just cannot get the two results into the dropdown...[/quote]

No matter what, the 2nd return will never be returned. Once you call return in a function, that's it. Nothing below it ever gets called. That's why I suggested combining an array and returning it. Perhaps, I never grasped what you are trying to do. Admittedly, I did not go over every line of code.
#13

[eluser]mdcode[/eluser]
Thanks bretticus, the one return things actually makes sense now, but unfortunately I still have the same problem as I cannot combine the arrays as you suggested given the fact that the value of the option selected, has to be the id number of the subtypes table. I think that I have just thought of another way to get half way there, so I'll pose another question in another thread along the same lines to see if it can get closer to what I am attempting to achieve in this one.




Theme © iAndrew 2016 - Forum software by © MyBB