stanl author 9/1/2014 | |
I think this is very simple, I just can't get the last piece. The two lines below work, but I have supplied the employee id number found in the selected record for the manager table. I have two tables employeegoals and manager. There is a parent child relationship in that the manager has employees that have mulitple goals in employeegoals table. Each goals has a percentage and I am trying to sum percentage for an employee from employeegoals and update the field employeepercent in the manager table. I added a button and put this code in the server event to update the items selected. What am I doing wrong with the following code? Thanks global $dal; while ( $data = $button->getNextSelectedRecord() ) { // The following sql statement works to update if I hard code the percent //$sql = "Update manager set EmployeePercent='55' where manager_pk=".$data["manager_pk"]; //But I want to use the following to sum from the other table when the employee is selected and then update. $sql = "select SUM(Percentage) FROM employeegoals where employeegoals.employee='manager.employee'"; CustomQuery($sql); $sql2 = "Update manager set EmployeePercent='$sql' where manager_pk=".$data["manager_pk"]; CustomQuery($sql2); } $result["txt"] = "Records were updated."; |
admin 9/1/2014 | |
Check example at http://xlinesoft.com/phprunner/docs/update_multiple_records.htm |
stanl author 9/2/2014 | |
Sergey, Check example at http://xlinesoft.com/phprunner/docs/update_multiple_records.htm $data["FieldNameHere"] gives access to any field of selected record on the List page. |
admin 9/2/2014 | |
Print your SQL query instead of executing it to see what went wrong. This is the only way to find what is wrong. |