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.
in MySQL (i guess you are using phpmyadmin) type:
SELECT * FROM
tblName
;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
Use the query of step 1, and use the print() to output in the browser.
Until this point you'll have the ugliest page, but you have completed the basis for connecting to database within a browser.
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.
Now you are almost finished and you can use javascript to manipulate the data.
Download jQuery and use the built in animations, so your site doesn't look bad.
Come back to stackoverflow.com and you'll be able to ask a specific question about the logic for handling the sizes and colors.
精彩评论