poolhustler86 Posted February 28, 2008 Author Share Posted February 28, 2008 its not here the code.. its at the office.. thats the problem... the table with the prices... and qty breaks.. are within a form... when the customers clicks add to cart.. and there is data entered into the different qty boxes for that one product... how do i get that data into mysql shopping cart table i have. (products might have one or twenty different colours or sizes...eg blue, green,red..) basically how do u get each qty box on the table to be a different field name and get them to insert in db.. i can do the insert part... its getting the data from the form... cause i would take the item code number and qty from the table. and insert into shopping cart! Quote Link to comment Share on other sites More sharing options...
spikeon Posted February 28, 2008 Share Posted February 28, 2008 is that all u needed??? USE AN ARRAY!!! *cries echo weep(); Quote Link to comment Share on other sites More sharing options...
poolhustler86 Posted February 28, 2008 Author Share Posted February 28, 2008 ive never been good at arrays... so how do u get that data in an array() i feel so dumb.. but thats one part of programming i never picked up! Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 and, thorpe, i see no reason why not too. if you can pull it everywhere you need it just the same, and explode it, its like .00000003 ms longer It does get more complicated / slower when you need to search on these values, or remove them. Its easier to make a dynamic table, theres no complicated sql invloved. CREATE TABLE basket ( id INT AUTO INCREMENT PRIMARY KEY, user_id, item_id INT, qty INT, size INT ); Then if user 1 bought 2 size 10 item 1's and 3 size 4 item 1's. INSERT INTO basket (user_id,item_id,qty,size) VALUES (1,1,2,10); INSERT INTO basket (user_id,item_id,qty,size) VALUES (1,1,3,4); Im still not sure this is where the op is stuck however. Quote Link to comment Share on other sites More sharing options...
poolhustler86 Posted February 28, 2008 Author Share Posted February 28, 2008 its a php coding problem.. database side is fine... Quote Link to comment Share on other sites More sharing options...
spikeon Posted February 28, 2008 Share Posted February 28, 2008 well then thorpe, i could learn alot from you... i still like my way though, never liked using multiple tables Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 I agree with Thorpe on not storing imploded arrays in the database. It screws up searches, and is a bad practice as far as databases go. Quote Link to comment Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 i still like my way though, never liked using multiple tables What multiple tables? There is one table in my example. Quote Link to comment Share on other sites More sharing options...
spikeon Posted February 28, 2008 Share Posted February 28, 2008 <input name = 'name[]' type = textarea> <input name = 'name[]' type = textarea> <input name = 'name[]' type = textarea> <input name = 'name[]' type = textarea> will return 4 different results you can use with foreach($_POST[name] as $name) or something like that Quote Link to comment Share on other sites More sharing options...
spikeon Posted February 28, 2008 Share Posted February 28, 2008 there'd have to be a extra table in the db to store the different sizes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.