1

sorry for may english ;)

I created mysql structure based on sahalMoidu's from first answer here. What i would like to do is create in product page select boxes which will send values via ajax change(). Values will change SKU and price.

My question is - How select(grab) PRODUCT_VARIANTS_ID if i will send via ajax set of values and product_id? Of course if there is a variant containing all values

MySQL structure is like in http://sqlfiddle.com/#!2/37268/2/0 On this result there is no need to grab value names etc so mysql result can by like shown below

what i have at the moment is sorted variants in array

SELECT * FROM shop_product_Variants pv LEFT JOIN shop_product_details pd ON pd.product_Variants_id = pv.product_Variants_id  WHERE pv.product_id = 3

while($data = dbarray($result)) {


      $attr[$data['product_Variants_id']][] = $data['value_id'];

   }
print($attr);

the outpout is

Array ( 
        [3] => Array ( [0] => 1 [1] => 5 [2] => 6 ) 
        [4] => Array ( [0] => 1 [1] => 5 [2] => 8 ) 
      ) 

This shows two variants with values for this product_id - how to store in variable a product_Variant_id (srray_key) whose values (for example [1,5,8] or other sent via ajax) are in one of those arrays? if there is no variant with all values - print '0".

Any help/suggestions? Maby other array structure containing also variant_id or othermysql result?

Community
  • 1
  • 1
Medyq
  • 11
  • 2
  • Note that RIGHT JOINs are comparatively rare. For instance SO currently lists 1,192 mysql RIGHT JOINs as compared with 28,128 LEFT JOINS! Also, unless we're maybe talking about world debt, money is always DECIMAL, not FLOAT. And have you looked at json_encode? – Strawberry Jan 15 '14 at 13:21
  • Sorry - LEFT JOIN edited - I pasted wrong code ;) Yes - the mysql structure is not perfect - i will change it after i find solution for this issue - price will be int in final represented like $1,00 = 100 etc. Like i wrote :) i took structure written by someone else and try to find solution to grab variant proporties using pack of values :) data type are only sample not edited by me :) – Medyq Jan 15 '14 at 13:49

0 Answers0