J
|
Jane 1/15/2007 |
Hi, function BeforeDelete($where) { $result = mysql_query("SELECT , SUM(BlockTime) as oldhours FROM pirep WHERE ". $where." GROUP BY pilotname ORDER BY oldhours DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array( $result ); $oldhours = $row['oldhours']; // global $conn,$strTableName; $rs = db_query("select FieldName from ".$strTableName." where ".$where."",$conn); $data = db_fetch_array($rs); $IDPilot = $data["FieldName"]; //Get total amount of transferred hours $result = mysql_query("SELECT FROM vb3_userfield WHERE userid = ".$IDPilot." ") or die(mysql_error()); $row = mysql_fetch_object( $result ); $transferredhours = $row['field13']; //Determine if transferred hours is lower or higher than 100 if ($transferredhours >= 100) { $transferredhours = 50; } else { $transferredhours = 0; } //Add $oldhours and $transferredhours to get $totalhours $totalhours = $oldhours + $transferredhours; //Update the database with the final result of $totalhours $queryupdate = mysql_query("UPDATE vb3_userfield SET field9 = ".$totalhours." WHERE userid = ".$IDPilot." ") or die(mysql_error()); return true; }
|