php & mysql calculate anniversary date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
slhawk98
Forum Newbie
Posts: 2
Joined: Fri Jul 28, 2006 9:54 am

php & mysql calculate anniversary date

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
slhawk98
Forum Newbie
Posts: 2
Joined: Fri Jul 28, 2006 9:54 am

Post by slhawk98 »

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 - end

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]
Post Reply