so picking project quit halfway through last guy more practice php , databases. have run problem, , sure common enough there standard solution, unable find one.
the db working has 4,600, reorganizing out of question. db of liquers wholesaler. here results page looks currently:
what trying set results returned in list form, 1 title , dropdown menus different sizes/prices of products looks this:
the problem there multiple entries in db each product. in example there 3, while have 1, , have 2.
i not sure how go this, , appreciated. thank you.
i'm not sure php syntax, pseudocode here's do:
allproductsreturnedfrommysql = queryyourdatabaseforallproducts() hashtable[productid, list[productsizes]] dropdownsbyproduct; hashtable[productid, commonproductinformation] uniqueproducts; foreach (product in allproductsreturnedfrommysql) { if product.productid not in uniqueproducts add product information not vary if product.productid not in dropdownsbyproduct add empty list append size of product corresponding list in dropdownsbyproduct }
after little bit of logic you'll have unique products common properties each one, , way fetch corresponding sizes drop down. if wanted purely in sql minimize data that's transferred, this:
-- products select distinct id, property1, property2 product -- drop downs product select id, size product order id
you can build same drop down hashtable iterating through second result set.
Comments
Post a Comment