Using SUM on Update
I'm sure this is covered somewhere in the forum. I want to take the sum of two values from two columns (SQL) from 1 id and update another column on Update from a webassist update page.
The two values would be the SUM of Day1_TotalWeight and Day2_TotalWeight to update Final_Weight
Thanks in advance!!!
<?php
$WADAAFTDirResult_update = new WA_MySQLi_RS("WADAAFTDirResult_update",$XXXXX,1);
$WADAAFTDirResult_update->setQuery("SELECT id, EventID, DQ, FullName, MemberID, Day2_Fish, Day2_Alive, Day2_Short, Day2_Penalty, Day2_BigBass, Day2_ScaleWeight, Day1_TotalWeight, Day2_TotalWeight, Points, Payout, Payout_Description FROM AFTDirResult WHERE AFTDirResult.id = ?");
$WADAAFTDirResult_update->bindParam("i", "".($_GET['id']) ."", "-1"); //Paramid
$WADAAFTDirResult_update->execute();
?>
<?php
if (isset($_POST["Update"]) || isset($_POST["Update_x"])) {
$UpdateQuery = new WA_MySQLi_Query($XXXXX);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "AFTDirResult";
$UpdateQuery->bindColumn("DQ", "s", "".((isset($_POST["DQ"]))?$_POST["DQ"]:"") ."", "WA_BLANK");
$UpdateQuery->bindColumn("Day2_Fish", "d", "".((isset($_POST["Day2_Fish"]))?$_POST["Day2_Fish"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Day2_Alive", "d", "".((isset($_POST["Day2_Alive"]))?$_POST["Day2_Alive"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Day2_Short", "d", "".((isset($_POST["Day2_Short"]))?$_POST["Day2_Short"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Day2_Penalty", "d", "".((isset($_POST["Day2_Penalty"]))?$_POST["Day2_Penalty"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Day2_BigBass", "d", "".((isset($_POST["Day2_BigBass"]))?$_POST["Day2_BigBass"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Day2_ScaleWeight", "d", "".((isset($_POST["Day2_ScaleWeight"]))?$_POST["Day2_ScaleWeight"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Day2_TotalWeight", "d", "".((isset($_POST["Day2_TotalWeight"]))?$_POST["Day2_TotalWeight"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Points", "d", "".((isset($_POST["Points"]))?$_POST["Points"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Payout", "d", "".((isset($_POST["Payout"]))?$_POST["Payout"]:"") ."", "WA_ZERO");
$UpdateQuery->bindColumn("Payout_Description", "s", "".((isset($_POST["Payout_Description"]))?$_POST["Payout_Description"]:"") ."", "WA_BLANK");
$UpdateQuery->addFilter("id", "=", "d", "".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"") ."");
$UpdateQuery->execute();
$UpdateGoTo = "ResultD2_detail.php?id=".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"") ."".(isset($_GET["pageNum_WADAAFTDirResult"])?"&pageNum_WADAAFTDirResult=".intval($_GET["pageNum_WADAAFTDirResult"]):"") ."";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>