MySql, for-loop, array help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mischievous
Forum Commoner
Posts: 71
Joined: Sun Apr 19, 2009 8:59 pm

MySql, for-loop, array help

Post by mischievous »

Hey Guys I have another question for yall... I am trying to setup a function that will display product options of any particular product stored in a DB...

Setup:
I have 4 tables: Product Table, Sku Table, Product_options table, and Product_attributes table...

The product_attributes table has an ID field, pd_id, and attribute(color, size, etc.)

The product_options table has an ID field, pd_attr_id, name, and sku_id;

I have started writing out a script that will basically display the attribute name... and then to the right display all the options of that attribute inside a dropdown menu... But im stuck and not sure where to go from here...

Any help would be greatly appreciated!

Code: Select all

 
        $query = "SELECT * FROM product_attributes LEFT JOIN product_options ON product_attribute.sku_id=$product WHERE product_attribute.id = product_options.pd_attr_id ";
        $queryresult = $this->db->query($query);
        $i = 0;
        foreach($queryresult->result() as $row)
        {
            $optionsArr[$row->attribute] = array( 
                'name' => $row->name,
                'sku' => $row->sku_id
                );
        }
        for($i = 0; $i >= count($optionsArr[$row->attribute]; $i++)){
        }
 
Post Reply