J
|
Jane 8/17/2009 |
Hi, |
A
|
acpan 8/17/2009 |
You can use MySQL Query such as Hi, i've do this code for calculate the maintenance of the machine based on Km, this code write a line in another table 'SCADENZIARIO' whit de results, but What can I do to check if the record already exists ?? This is my working code global $conn; $esc = 0; $next = 0; $tagli = 0; $i = $values["KmFine"]; $id = $values["IdTarga"]; //$str = "select SogliaTagliando from anagraficaautomezzi where Id=".$id; $str = "select SogliaTagliando from anagraficaautomezzi where Id='".$id."'"; $rs = db_query($str,$conn); $data = db_fetch_array($rs); $p = $data["SogliaTagliando"]; do { if ($i < $tagli) { $next = $tagli - $i; $strSQLInsert = "insert into scadenziario (IdTarga, TipoScadenza, note, ProssimoTagliando, ScadenzaGestita) values ('".db_addslashes($values["IdTarga"])."', 'TAGLIANDO', $i, $next,0)"; db_exec($strSQLInsert,$conn); $esc = 1; } else { $tagli = $tagli+$p; } } while ($esc == 0); |