doumi9618 2014-01-15 13:11
浏览 68

选择具有属性值的产品变量

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 Keil编译时报错"no source": Error: #5: cannot open source
    • ¥50 操作系统时间无法更新
    • ¥20 Windows11, usb转hdmi,外接显示器无反应
    • ¥20 怎么在JavaFx的TableView中动态地添加数据。
    • ¥15 MFC里的工具栏按钮图标使用外部图片
    • ¥15 如何在 llama.cpp 服务器中实现用户登录功能的优化方案?(语言-c++)
    • ¥15 有会用octave 的吗,急!代做!好偿!
    • ¥15 有一套同城小程序源码,Uniapp前端,php+html+mysql后端 ,能不能教我搭建起来可以运行,我不知道怎样操作
    • ¥15 mac调用java.io接口无法在根目录生成文件
    • ¥15 java微服务节点假死,网关路由时长延迟