Jump to content

Recommended Posts

I apologise if this has been asked many times but I cant find an accurate answer.

 

Problem:

 

I have a shopping cart.

The technical data required for each record is extensive with 42 fields per record.

I wish to give the user the option to duplicate the cart entry x number of times.

 

Question:

Is there a way of duplicating the record into the same table with a single insert statement without listing the 42 fields in the statement?

 

I have tried many things including INSERT INTO cart SELECT * FROM cart  WHERE record_number=1 .

 

record_number is an auto_increment field which creates the error of a Duplicate key.

 

Any help is greatly appreciated.

 

Mysql version 4.1 and PHP Version 5.2.10

Link to comment
https://forums.phpfreaks.com/topic/178319-help-with-insert/
Share on other sites

Is there a specific reason that you want to let users duplicate items in the cart? Isnt the usual method to update the quantity field?

 

If you still want to use your method, then dont do a 'SELECT *...' - specify the exact fields that you want to copy (obviously leaving out the record_number field)

Link to comment
https://forums.phpfreaks.com/topic/178319-help-with-insert/#findComment-940272
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.