9911782 Posted May 26, 2006 Share Posted May 26, 2006 Hi AllI 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:-------------------------------------------------------<?phprequire_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; 60secsecho '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.phpif ($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 Quote Link to comment https://forums.phpfreaks.com/topic/10488-calc-end-date-of-event/ Share on other sites More sharing options...
ryanlwh Posted May 26, 2006 Share Posted May 26, 2006 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--] Quote Link to comment https://forums.phpfreaks.com/topic/10488-calc-end-date-of-event/#findComment-39276 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.