This topic is locked

Expire Date Calculation

7/7/2011 6:32:28 AM
PHPRunner General questions
S
sickacid author

In after record add, i've put this code, i get date from add page field and a type of item, in case of a specific item is flagged by $flag_sc, the code'll write a record in a specific talble, and it works, but when i go to calculate the EXPIRATION DATE of item, i got the problem, i can't get the date to write to db, che code fill every field of destination table, but not data_scadenza, where i'm going to put che expiration date, the field is set a date field in the mysql... please help me! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=17317&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />
//get ID from page

global $dal, $strTableName;

if ($_SESSION[$strTableName."_masterkey1"])

{

$tblOrders = $dal->Table("anagraficaautomezzi");

$rs = $tblOrders->Query("ID=".$_SESSION[$strTableName.

"_masterkey1"],"");

if ($data = db_fetch_array($rs))

{

echo "Info sessione: TARGA: ".$data["Targa"]." ", "ID TARGA: ".$data["ID"]."
";

}

}
global $conn;

// ASSEGNAZIONE VARIABILI

$IdTarga = $data["ID"];

$IdApparato = $values["Tipo_dispositivo"];
// Reserch params for a specific items

$str = "select from anagraficaattrezzature where Id='".$IdApparato."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$flag_sc = $data["Scadenza"]; //Get Flag for expire or not

$durata = $data["Durata_gg"]; //Get During DAYS
$expiredate = date("Y-m-d",strtotime($values["DataAssegnazione"])+(60
6024$durata));
//Write a new record to another table

if ($flag_sc == 1)

{

$strSQLInsert = "insert into tabella_scadenze (Id_targa, data_scadenza, scadenza_gestita, Id_apparato,note ) values ($IdTarga, $expiredate, 0,$IdApparato, $expiredate)";

db_exec($strSQLInsert,$conn);

return true;

}

C
cgphp 7/8/2011

Try to echo the $expiredate before to insert it in tabella_scadenze.