close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Incremental Dates for each record

Thread began 5/27/2009 2:15 am by acaciasd344844 | Last modified 5/29/2009 8:26 am by acaciasd344844 | 3821 views | 10 replies |

acaciasd344844

Incremental Dates for each record

Hi All,

I am afraid that I am not a php programmer, just a dreamweaver user with a DataAssist server behaviour.

I have created a page which allows users to set up a pre-selected number of pre-payments i.e 1-12, as well as frequency i.e 7, 14, 28 etc as well as a selected date i.e. this can be any date in the future.

This means that I need to enter the first date that they select into the first record then increment each date for the following number of records/pre-payments and the date should increment by the frequency.

I have used dataassist to create the multiple inserts but am stuck on how I should proceed.

So far, I have a hidden date field which I have added the following code...

<input name="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php $date = $row_Recordsetcustomers['date'];
$frequency = $row_Recordsetcustomers['frequency'];
$newdate = strtotime ( '+ 7 day' , strtotime ( $date) ) ;
$newdate = date ( 'Y-m-d H:i:s' , $newdate); echo $newdate; ?>[" />

The repeat selection counter is part of the dataassist server behaviour, so has to remain within the page. The section in bold is the code that I have added. The '+ 7 day' will be the frequency variable.

It appears to add the advanced date, not the initial selected date; and then adds this date to all the pre-payments/records.

Hopefully some one can guide me as to where I am going wrong!

Thanks in advance


John Henderson

Sign in to reply to this post

Ray BorduinWebAssist

Add code to the top of the page just below the recordset, or at least somewhere above the loop like:

<?php $writeDate = $row_Recordsetcustomers['date']; ?>

Then in the form use:

<input name="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo date ( 'Y-m-d H:i:s' , $writeDate); ?>" />
<?php
$writeDate= strtotime ( '+ 7 day' , strtotime ( $writeDate) );
?>

Sign in to reply to this post
Did this help? Tips are appreciated...

acaciasd344844

Originally Said By: Ray Borduin
  Add code to the top of the page just below the recordset, or at least somewhere above the loop like:

<?php $writeDate = $row_Recordsetcustomers['date']; ?>

Then in the form use:

<input name="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo date ( 'Y-m-d H:i:s' , $writeDate); ?>" />
<?php
$writeDate= strtotime ( '+ 7 day' , strtotime ( $writeDate) );
?>  


Thanks will give it a go

john

Sign in to reply to this post

acaciasd344844

Hi Ray,

Thanks for your assistance with the php code; It works but not quite!
I added the code to where you recommended but the results for some reason are unexpected.
The date does appear in all the records, but they appear as the following

record1DATE 1970-01-01 01:33:29
record2DATE 2009-06-04 09:17:02
record3DATE 1970-01-08 01:00:00
record4DATE 1970-01-08 01:00:00
record5DATE 1970-01-08 01:00:00
record6DATE 1970-01-08 01:00:00


The system allows up to 12 records to be created at a time. I tested it a number of times, but the outcome is always the same. Confusing dates!


The additional require ment is that the No '7' in the code becomes a variable
+ 7 day, and this would be $row_Recordsetcustomers['frequency']

I could not get that to work either. I kept getting a parse error.

The frequency field can contain a number of different values, this is why it is needed.


Thanks again Ray, for your time and assistance


regards


john henderson

Sign in to reply to this post

Ray BorduinWebAssist

Add code to the top of the page just below the recordset, or at least somewhere above the loop like:

<?php $writeDate = strtotime($row_Recordsetcustomers['date']); ?>

Yeah I based the code on the assumption that your code was basically working. I see now that you had a flaw in your logic when incrementing the date in general:

<input name="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" type="hidden" id="hf_date_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo date ( 'Y-m-d H:i:s' , $writeDate); ?>" />
<?php
$writeDate= strtotime ( '+ '.$row_Recordsetcustomers['frequency'].' day' , date('Y-m-d H:i:s' , $writeDate) );
?>

(incidentally I don't have time to test this, so you may need to do a little debugging if you run into problems. The concepts should be sound)

Sign in to reply to this post
Did this help? Tips are appreciated...

acaciasd344844

Thanks Ray will give it a go in the morning UK time

will let you know the outcome

regards

john

Sign in to reply to this post

acaciasd344844

Thanks for what youve done Ray

I just wondered does this kind of principle reflect what i am after...

date = date + 1

because the code we have so far does not reflect this!

what do you think?

john

Sign in to reply to this post

Ray BorduinWebAssist

I don't understand the question. That doesn't appear to be valid php code.

Sign in to reply to this post
Did this help? Tips are appreciated...

acaciasd344844

Once again thanks for your able assistance, I would not have got this far without you.


I have managed to get the dates to increment and figured out how the system is looping etc.

It just appears now that the date the code is supposed to increment is replaced by '1970-01-01', obviously a system start time.

I have been really trying to get this to work but my lack of php knowledge is rather telling.

this is what i have so far...


*** I put the variable above the begin loop section:


<?php $writeDate = $row_Recordsetcustomers['date']; ?>
<?php
// RepeatSelectionCounter_1 Begin Loop



*** I created a visible test field so that I can see the results before they enter the system. This sits with the hidden fields

<input name="textfield" type="text" id="textfield" value="<?php echo date ('Y-m-d H:i:s' , $writeDate); ?>" />



*** I put the final bit of code in the RepeatSelectionCounter_1 End section


<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_Recordsetpayments && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_Recordsetpayments = mysql_fetch_assoc($Recordsetpayments);
$writeDate = strtotime('+7 days', $writeDate);
}
$RepeatSelectionCounter_1++;


} // RepeatSelectionCounter_1 End Loop

All this works except for the fact that the $row_Recordsetcustomers['date'] is not picked up and incremented and the following code you provide previously
stopped the increment from working altogether...

$writeDate= strtotime ( '+ '.$row_Recordsetcustomers['frequency'].' day' , date('Y-m-d H:i:s' , $writeDate) );


could all this be something to do with the php version I have? Or do I need to use Global variables?

Sorry to pester, Ray, but I have to have this bit done by the end of this month (gulp).

Once again thanks in anticipation


john

Sign in to reply to this post

Ray BorduinWebAssist

The code on the top of the page should be:

<?php $writeDate = strtotime($row_Recordsetcustomers['date']); ?>

and to increment I think you are going to have to use:

$writeDate = strtotime('+7 days', date('Y-m-d H:i:s' , $writeDate));

you need to learn how to debug if you are going to try to write php code by hand. Have you tried adding die() and echo() statements to your code so you can check when and where things are going wrong? Are you looking for code examples on php.net and trying to adjust lines of code when there are errors?

I like helping, but debugging and writing custom code go hand in hand. You should learn debugging now before wasting this much time in the future. If you knew how to debug this problem would have been solved in the first hour of working on it and you wouldn't be worried about your deadline.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...