I am working on a membership application using php & mysql and need to calculate the membership anniversary date and enter the calculated date into the ENDDATE filed of the _MEMBERS table. Any suggestions or example scripts.
Example: 6/27/2007 + 365 days = 6/26/2008
_MEMBERS table
`ID`,
`fname`,
`middle`,
`lname`,
`dob`,
`startdate`,
`enddate`,
`memtype`
Thanks
php & mysql calculate anniversary date
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
"enddate" being a date field?
startdate + INTERVAL 365 DAY, potentially, or startdate + INTERVAL 1 YEAR.
http://dev.mysql.com/doc/refman/5.0/en/ ... n_date-add
startdate + INTERVAL 365 DAY, potentially, or startdate + INTERVAL 1 YEAR.
http://dev.mysql.com/doc/refman/5.0/en/ ... n_date-add
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks, your reply make since. I think I have found the code I believe needs to be changed but not sure how to change the code to display "startdate + INTERVAL 365 DAY, potentially, or startdate + INTERVAL 1 YEAR" and update the database. Any pointers would be helpful.
You can view the entire content of this file at this URL:
[url]http://www.basicwebs.net/membership/_members_add.php.pdf[/url]
[b]Code[/b]Code: Select all
// processing enddate - start
$value = postvalue("value_enddate");
$type=postvalue("type_enddate");
if (in_assoc_array("type_enddate",$_POST) || in_assoc_array("value_enddate",$_POST) || in_assoc_array("value_enddate",$_FILES))
{
$value=prepare_for_db("enddate",$value,$type);
}
else
$value=false;
if(!($value===false))
{
$avalues["enddate"]=$value;
}
// processibng enddate - endfeyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]