This topic is locked

Add Field Value based on Drop Down Lookup

4/13/2009 5:20:50 AM
PHPRunner General questions
B
bjsaga author

Hi,
I am a newbie on PHP.
I am designing a timesheet database for my company. I have the a table "timesheet" with following field (timesheetid, employee, empno, workdate, totalhour,unitrate). The unitrate is a field dependent upon the value of `empno` which is linked to a table called "employee" with field (empno,unitrate).
I have two groups, employee and admin.
I create a TimesheetList page consisting of (timesheetid, employee, empno, workdate, totalhour). I also create an Add page in which employee could input their timesheet to the system with the following field (timesheetid, employee, empno, workdate, totalhour).
What I want is that whenever an employee add a record eventhough in the Add page, there's no `unitrate` field, it could automatically add `unitrate` value to the 'timesheet' table. The unitrate will be accesible only by admin through a different page called 'timeadmin ' which consists of the following field "timesheetid, employee, empno, workdate, totalhour,unitrate"
Regards,

J
Jane 4/13/2009

Hi,
to fill unitrate field automatically use Before record added/Before record updated events on the Events tab.

Here is just a sample:

global $dal;

$rs = $dal->employee->Query("empno=".$values["empno"],"");

if ($data = db_fetch_array($rs))

$values["unitrate"] = $data["unitrate"];

B
bjsaga author 4/14/2009

Thanks Jane,
It works great