I have code in PHPRunner ( after record updated ) to Update a master table with the total number of hours worked based on the details table (multiple entries ) but when I add a sencond WHERE clause into the $strUpdate I get the syntax error.
I have change the code multiple times and is not working with the WHERE and the AND clauses. If I delete AND (Date=$values[DateField1])
and remove the () it calculates the totals, the only problem is that it adds the total to all my master tables Hours fields instead of the one for that date only.
$mykey=$values["OwnerID"];
$mykey1=$values["DateField1"];
global $conn;
$str = "select SUM(Hours)AS [Hrs] FROM Attendance WHERE OwnerID='{$mykey}' Group by DateField1";
$rs = db_query($str);
$value = db_fetch_numarray($rs);
$total=$value[0];
$strUpdate = "update HrsOT set `DailyHrs`='{$total}' Where ((OwnerID='{$mykey}') AND (Date=$values[DateField1])";
db_exec($strUpdate,$conn);
return true;
I have look at sample codes and read sql / msaccess query pages online and cant find the reason for the error. Any help is very much appreciated