Jump to content


Photo

start_date and end_date changing via for loop


  • Please log in to reply
2 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 May 2006 - 05:13 PM

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

I want $end_date to insert in to database as 01-01-07

my example to get the $start_date to x 12 and insert $end_date but 12 months ahead of start_date.
<?

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 07 May 2006 - 06:00 PM

$start_date = "01-01-06"; // guesses that's day, month, year
list($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)); 

Legend has it that reading the manual never killed anyone.
My site

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 May 2006 - 06:07 PM

[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]solved[!--sizec--][/span][!--/sizec--]


subcripton date from and to by one year

Thank you [!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--]andyb[!--sizec--][/span][!--/sizec--]

<?

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users