Jump to content

Recommended Posts

I am trying to find a way to copy a number of records from db 3 back into db 3, only changing the date of the copied records

 

I have a PHP script that I use to record calories.

 

I do this by entering items eaten during the day.

 

I enter a food item from a dropdown menu. These items are in db 4 and each has the calorie count, protein, fat etc. for that item

 

The script places the item and data from tbl 4 into tbl 3

 

So I enter maybe 15 items for each day, all unique except the $day variable which is the same in all the entries (say 15 records) since all items belong to that day

 

I find it convienient now to copy a days worth of entries (15 entries in this example) from tbl 3 back into tbl 3, except change the $day variable from yesterday to today

 

This is so that I do not need to enter the same items again for multiple days - boring, tedious, waste of time, etc.

 

So if I plan to eat the same items today as I did on a past day, 

 

    The script asks for the original day, then the new day   

    so far so good

    It then needs to copy the original days entries back into the db, only changing the date field from the old date to the new date for each of the entries

 

I am sure this is simple, I just don't have enough experience to know how to make it happen.

 

Someone on the sight showed me how to copy 1 record, but I need to copy multiples.

 

So, I carry in the $original_date and the $new_date

 

the fields for tbl 3 are as follows:

 

day,

type,

history period,

item,

amt,

calorie,

fat,

fat_calories,

protein,

carb,

sugar,

sodium

 

Anyone have an answer for this one?

 

Thanks!!

 

David

 

 

Link to comment
https://forums.phpfreaks.com/topic/231079-copy-several-records-into-same-db/
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.