Welcome Guest, Not a member yet? Register   Sign In
[RESOLVED] 'Array to string conversion' error when using query to obtain dropdown list values from database.
#3

[eluser]Tim in Tulsa[/eluser]
Thanks, Adam!

Yes... Here's the getDomainList() function in the model:

Code:
function getDomainList($table_name = '')
        {
            $this->load->database();
            if(!empty($table_name))
            {
                $table_fields = $this->db->list_fields($table_name);
                
                $query = $this->db->get($table_name);
                
                if($query->num_rows() > 0)
                {
                    $domain_list = array();
                    foreach($query->result() as $row)
                    {
                        $keys[] = $row->$table_fields[0];
                        $values[] = $row->$table_fields[1];
                    }
                    
                    $domain_list = array_combine($keys, $values);
                }
                
                print_r($domain_list);
            }
            
            return $domain_list;
        }

As I mentioned in the original post, print_r($domain_list) is just here for debugging purposes (so that I can see that the array is properly formed).

Thanks for any suggestions/ideas. If there's a better way to do this, I'd appreciate your recommendation.

Tim


Messages In This Thread
[RESOLVED] 'Array to string conversion' error when using query to obtain dropdown list values from database. - by El Forum - 06-23-2010, 10:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB