redarrow Posted May 7, 2006 Share Posted May 7, 2006 I am trying to set up the dates for the subscription by 1 year.If the user signs up the database enters the start_date, Then i want the start_date to x by 12 months so the end date becomes 1 year later.my example below uses a for loop but i need help cheers.$start_date is 01-01-06I want $end_date to insert in to database as 01-01-07my example to get the $start_date to x 12 and insert $end_date but 12 months ahead of start_date.[code]<?$db=mysql_connect("localhost"):mysql_select_db("test",$db);$start_date=date("d-m-y");list($d,$m,$y) = explode("-", $start_date); $end_date = date("d-m-y", mktime(0,0,0,$m,$d,$y+2001)); $query="INSERT INTO dates (start_date,end_date)VALUES('$start_date' ,'$end_date')";$result=myql_query($query);$query_date="SELECT * from dates";$result_date=mysql_query($query_date);while($row=mysql_fetch_assoc($result_date) {echo "<br> Your subcription start date is '".$row['start_date']."' <br> Your subcription end date is '".$row['end_date']."'<br>"exit;}?><form method="post" action""><input type"hidden" name"start_date"><input type="hidden" name="end_date"><input type="submit" value"enter dates"></form>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted May 7, 2006 Share Posted May 7, 2006 [code]$start_date = "01-01-06"; // guesses that's day, month, yearlist($d,$m,$y) = explode("-", $start_date); // get components of the 'date'$end_date = date("d-m-y", mktime(0,0,0,$m,$d,$y+2001)); [/code] Quote Link to comment Share on other sites More sharing options...
redarrow Posted May 7, 2006 Author Share Posted May 7, 2006 [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]subcripton date from and to by one yearThank you [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]andyb[!--sizec--][/span][!--/sizec--][code]<?$db=mysql_connect("localhost","xxxx","xxxx");mysql_select_db("dates",$db);$start_date=date("d-m-y");list($d,$m,$y) = explode("-", $start_date); $end_date = date("d-m-y", mktime(0,0,0,$m,$d,$y+2001)); $query="INSERT INTO test (start_date,end_date)VALUES('$start_date' ,'$end_date')";$result=mysql_query($query);$query_date="SELECT * from test";$result_date=mysql_query($query_date);while($row=mysql_fetch_assoc($result_date)) {echo "<br> Your subcription start date is ".$row['start_date']." <br> Your subcription end date is ".$row['end_date']."<br>";exit;}?><html><body><form method="post" action""><input type"hidden" name"start_date"><input type="hidden" name="end_date"><input type="submit" value"enter dates"></form></body>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.