473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

wrong dates in a schedule

Hi Everyone,

I am using the following code (many thanks for the code folks BTW) to
generate 3 schedules in three tables one is a schedule with 7 day
intervals and two are daily schedules.

The two daily schedules seem to have out of sync dates at the start of
each schedule. The dates look as if they may be dates from the
preceding loop.

I am presuming that I need to reset something after the completion of
each loop but I am not sure what.

Many thanks

Darren

$now = time();
$day = $now + 7*24*60*60;
$cutoff = strtotime("+$months months");
while ($day <= $cutoff) {
$date = date('Y-m-d', $day);
$insert = "INSERT INTO daily_data SET subscr_id='$subscr_id',
date='$date'";
mysql_query($insert);
$day = $day + 7*24*60*60;
}
//then create a daily schedule in the excercise table
for($i=0;$i<=($sched);$i++)
mysql_query("INSERT INTO exercise_data SET subscr_id='$subscr_id',
date=date_add(now(),INTERVAL
LAST_INSERT_ID() DAY)");
//then create a daily schedule in the food and diet table
for($i=0;$i<=($sched);$i++)
mysql_query("INSERT INTO food_data SET subscr_id='$subscr_id',
date=date_add(now(),INTERVAL
LAST_INSERT_ID() DAY)");

Sep 21 '05 #1
1 1781
>I am using the following code (many thanks for the code folks BTW) to
generate 3 schedules in three tables one is a schedule with 7 day
intervals and two are daily schedules.

The two daily schedules seem to have out of sync dates at the start of
each schedule. The dates look as if they may be dates from the
preceding loop.
... date=dateadd(now(), INTERVAL LAST_INSERT_ID() DAY) ...

This is absolutely wierd. Shouldn't that be INTERVAL 7 DAY?
After you have a lot of people sign up, LAST_INSERT_ID() is going
to be a couple hundred or thousand, and certainly isn't what you
want. I also note that you never seem to use $i within the loops.
Perhaps that's what you want instead of LAST_INSERT_ID()?

You also never set $sched.
I am presuming that I need to reset something after the completion of
each loop but I am not sure what.

Many thanks

Darren

$now = time();
$day = $now + 7*24*60*60;
$cutoff = strtotime("+$months months");
while ($day <= $cutoff) {
$date = date('Y-m-d', $day);
$insert = "INSERT INTO daily_data SET subscr_id='$subscr_id',
date='$date'";
mysql_query($insert);
$day = $day + 7*24*60*60;
}
//then create a daily schedule in the excercise table
for($i=0;$i<=($sched);$i++)
mysql_query("INSERT INTO exercise_data SET subscr_id='$subscr_id',
date=date_add(now(),INTERVAL
LAST_INSERT_ID() DAY)");
//then create a daily schedule in the food and diet table
for($i=0;$i<=($sched);$i++)
mysql_query("INSERT INTO food_data SET subscr_id='$subscr_id',
date=date_add(now(),INTERVAL
LAST_INSERT_ID() DAY)");


Gordon L. Burditt
Sep 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: raj chahal | last post by:
Hi there, I'm creating a access database for 'events'. I have created a field for 'date of event', the asp then checks if this date has lapsed, if so it doen't show the event. All works fine....
8
by: MLH | last post by:
Anybody's solution would be appreciated. Pls, do not pause to write anything for this. I'm not looking for that kind of a handout. I have an idea about how to do it, but I wanted to see if anyone...
2
by: atv | last post by:
Hi, is there something wrong with this code? It seems that it crashes at the else { clause, when allocating a second record. Excuse for the indentation, the g_warnings are from gtk. Also, i'm...
4
by: Good Man | last post by:
Hi there I have a list of jobs scheduled in a MySQL table, with start dates and end dates, like so: SchedID | JobID | StartDate | EndDate |...
9
by: Greg | last post by:
Hi, I have a table with "dates", i'd like to display those dates on a calendar. I've put a calendar in a form, linked to my "date" field, and it works, but only showing one "date" per calendar....
1
by: josecruz | last post by:
I have to create a summary report that will provide counts and # average of days for multiple "Status" by entering different dates for every criteria. I have created several queries that calculates...
2
by: Eamon | last post by:
Hi all, I'm trying to find a way to list all the jobs/schedules due to run between two dates but all I seem to be able to get is a list of jobs with their NextRunTime. Example: Say I had two...
4
by: Ruben | last post by:
Hi, I have a continuous form that provides a listing of various instruments that are serviced on a monthly to annual basis, with general info about the instrument, last and next service dates,...
2
by: BeckR | last post by:
Hello: Thanks for reading my post. I am trying to generate Athletic League schedules using Access 2003 and Windows XP PRO. I am using DateSerial in a text box to print the game dates on the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.