MySql, for-loop, array help
Posted: Fri May 29, 2009 3:29 pm
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!
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++)){
}