开发者

Dependent radio buttons or checkbox or other methods via PHP and Jquery

I have the following mySQL database:

options_id, options_name, options_child, quantity
1, Small, White, 10
2, Small, Pink, 10
3, Medium, White, 2
4, Medium, Pink, 0
5, Large, White, 0
6, Large, Pink, 5

Basically I have to output this in radio buttons or 2 dropdowns or maybe some other method and pass the data back to php.

The challenge is that the output has to be dependant on the quantity. So there will be 2 drop downs for example.

One for Sizes and one for Colors. If someone selects Medium Size, based on the above quantity mentioned, there are 0 for Pink. So basically that will be out of stock.

开发者_开发百科

Someone recommended that output the data as an array and then use javascript for that.

I will be using jQuery for output something like this: Amazon-like interface for selecting product size and color (i.e., click a little red box to select a red product, etc)

Any help is much appreciated.

Thanks


Your project can be done like in an hour, but you need to follow some steps.

  1. in MySQL (i guess you are using phpmyadmin) type:

    SELECT * FROM tblName;

  2. Search php examples for connecting to MySQL database:

    You'll need to put your username/pwd and the server IP:PORT in a configuration file

  3. Use the query of step 1, and use the print() to output in the browser.

  4. Until this point you'll have the ugliest page, but you have completed the basis for connecting to database within a browser.

  5. Then, use a program like dreamweaver to draw the layouts, and search for php snippets (dreamweaver has built in examples) for propagating the radio buttons and checkboxes.

  6. Now you are almost finished and you can use javascript to manipulate the data.

  7. Download jQuery and use the built in animations, so your site doesn't look bad.

  8. Come back to stackoverflow.com and you'll be able to ask a specific question about the logic for handling the sizes and colors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜