Jump to content

Calc end date of event


9911782

Recommended Posts

Hi All

I can't move now. I've been trying to calculate the end date(due date in 3months time) for a specific event by getting the startdate from the database then calculate the end date.I think I got it, but now the problem is that, I want to write it to my dababase using the update statements. It doesn't want to write now. What can I do? What have a done wrong here???

ps help me good people

here is my small code:

-------------------------------------------------------
<?php
require_once('inc_conn.php');
$edatetime = $_POST['edatetime'];
// prepare query
$sql="SELECT sdatetime FROM eventscalendar";
//execute sql statements
$rsdate = mysql_query($sql, $connimgp) or die(mysql_error());
//retrieve one row of records
$sdatetime = mysql_fetch_array($rsdate);
//determine the number of records in recordset
$num_rows = mysql_num_rows($rsdate);
//echo $sdatetime['sdatetime'];
$sdatetime= $sdatetime['sdatetime'];
echo "<br>";
$edatetime = time() + (61 * 24 * 60 * 60);
// 7 days; 24 hours; 60 mins; 60secs
echo 'Date Posted: '. $sdatetime ."<br><br>";
echo '3 month due date: '. date('Y-m-d', $edatetime) ."\n";

//Insert into the database
$insertSQL = "UPDATE eventscalendar SET edatetime = '".$edatetime."' WHERE eventid=49";
//Execute the insert statement
$execute = mysql_query($insertSQL, $connimgp) or die(mysql_error());
//Redirect to policy.php
if ($execute) {
mysql_close($connimgp);
}
?>

-----------------------------------------------------------------------

What could be the problem here? Please help me....I've been trying to this for 2days now. Can somebody provide me with his/her own source code to help me.

thank you
Link to comment
https://forums.phpfreaks.com/topic/10488-calc-end-date-of-event/
Share on other sites

because, in the update query, you always update eventid49...

by the way, there's an easier way to do this thing:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] eventscalendar SET edatetime[color=orange]=[/color](sdatetime [color=orange]+[/color] INTERVAL 3 MONTH) [color=green]WHERE[/color] eventid[color=orange]=[/color]49 [!--sql2--][/div][!--sql3--]
Link to comment
https://forums.phpfreaks.com/topic/10488-calc-end-date-of-event/#findComment-39276
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.