Jump to content

start_date and end_date changing via for loop


redarrow

Recommended Posts

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.
[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]
Link to comment
Share on other sites

[code]$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));
[/code]
Link to comment
Share on other sites

[!--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--]

[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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.