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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.