Jump to content


Photo

Calc end date of event


  • Please log in to reply
1 reply to this topic

#1 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 26 May 2006 - 09:03 AM

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

#2 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 26 May 2006 - 08:02 PM

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=(sdatetime + INTERVAL 3 MONTH) WHERE eventid=49 [!--sql2--][/div][!--sql3--]
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users