Welcome Guest, Not a member yet? Register   Sign In
Load drop down box from database
#1

[eluser]maddtechwf[/eluser]
I have written some code to read item's from my db and then use them to populate my drop down box on my view. When I add the code and try it, my page just shows to be blank. I don't get any errors on the page what so every. Can anyone help me with this.

Model
Code:
//Get Gategories
        function get_categories($category_type)   //the $category_type is a string value passed from controller
        {
            $return = array();
            
            //DB Connection
            $this->db->select('ID,Name');
            $this->db->from('Category');
            $this->db->where('Type='.$category_type);
            $category_items = $this->db-get();
            
            if ( $cagetory_items > 0)
            {
                foreach ( $category_items->results() as $item)
                {
                    array_push($return, $item);
                }
            }
            return $return;
        }

Controller
Code:
$data['example_Categories'] = $this->map_model->get_categories("test123");

View
Code:
<select>
                    &lt;?php
                        $ucat = $map['example_Categories'];
                        
                        foreach ( $ucat as $item )
                        {
                            echo "<option name=".$item-&gt;Name." value=".$item-&gt;ID.">".$item->Name."</option>";
                        }
                    ?&gt;
                </select>


Messages In This Thread
Load drop down box from database - by El Forum - 05-30-2013, 01:24 PM
Load drop down box from database - by El Forum - 05-30-2013, 03:12 PM
Load drop down box from database - by El Forum - 05-31-2013, 06:13 AM
Load drop down box from database - by El Forum - 05-31-2013, 11:49 AM
Load drop down box from database - by El Forum - 05-31-2013, 12:07 PM
Load drop down box from database - by El Forum - 05-31-2013, 12:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB