This topic is locked

Insert date interval based on drop down box selection

9/17/2009 12:57:10 AM
PHPRunner General questions
R
ragrim author

Ive hit a bit of a brick wall here, im trying to to a subscriptions table and basically i want to update the "expirydate" field based on the selection of a drop down box that has options of 1, 2, 3,4 or 5 years. i have a subscriptions table and a subscriptiontype table which is the lookup for table which has the fields of ID, Displayname, Length. length being either days months or years which ever works best for the script. im assuming i need to add a custom on submit code or something which makes the value of expiry date todays date plus interval of days/years
any help on this would be muchly appreciated as its driving me nuts.

J
Jane 9/17/2009

Hi,
use Before record added/Before record updated events on the Events tab to calculate and save ExpireDate.

Here is a sample:

//DateField + `Length` days

$values["ExpireDate"] = date("d/m/Y",strtotime($values["DateField"]) + $values["Length"]*(60*60*24));
R
ragrim author 9/19/2009



Hi,
use Before record added/Before record updated events on the Events tab to calculate and save ExpireDate.

Here is a sample:

//DateField + `Length` days

$values["ExpireDate"] = date("d/m/Y",strtotime($values["DateField"]) + $values["Length"]*(60*60*24));



Thanks for the reply.
I cant seem to get it working, using your code it updates my expiredate field but it inserts the current date, not current date + X days

J
Jane 9/21/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.