Jump to content

How would you create this type of table?


poolhustler86

Recommended Posts

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!

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.

<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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.