Page 1 of 1
php & mysql calculate anniversary date
Posted: Thu Jun 28, 2007 7:52 am
by slhawk98
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
Posted: Thu Jun 28, 2007 8:07 am
by feyd
"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
Posted: Thu Jun 28, 2007 9:26 am
by slhawk98
feyd | Please use 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 - end
feyd | Please use 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]