This topic is locked
[SOLVED]

 Get Value From Another Table Depending From Main Field

6/24/2013 4:13:46 AM
PHPRunner General questions
A
angelcause author

I have a table EmployeeDatabase which has a database of Employee details with fields EmployeeName, EmployeeLogin, and Designation and have created another table RequestForm which has the fields EmployeeName, EmployeeLogin and Designation. Now I am using a default value of $_SESSION["UserID"] for the field EmployeeLogin and I want the other fields (EmployeeName and Designation) to be filled automatically from the EmployeeDatabase table.

C
cgphp 6/24/2013

You can learn more about Autofill here http://xlinesoft.com/phprunner/docs/lookup_wizard.htm

A
angelcause author 6/24/2013

Thanks, but even this is not filling the requirements.

I want it to automatically fill in the fields which are dependent on the Requestedby field which is using $_SESSION["UserID"]
Please see the attachment for understanding the required.

C
cgphp 6/24/2013

You are not working with lookup wizard. In the "Process" record values" event of the add page, execute the query to fetch the "Employee" and "Designation" values, based on the SESSION variable.

A
angelcause author 6/24/2013



You are not working with lookup wizard. In the "Process" record values" event of the add page, execute the query to fetch the "Employee" and "Designation" values, based on the SESSION variable.


Thanks again Christian, Please guide me with the code that will bring in the data from the EmployeeDatabase table for both the fields (EmployeeName and Designation)

C
cgphp 6/24/2013
$rs = CustomQuery("SELECT EmployeeName, Designation FROM RequestForm WHERE EmployeeLogin = '".$_SESSION["UserID"]."'");

$record = db_fetch_array($rs);
$values['EmployeeName'] = $record['EmployeeName'];

$values['Designation'] = $record['Designation'];
A
angelcause author 6/25/2013


$rs = CustomQuery("SELECT EmployeeName, Designation FROM RequestForm WHERE EmployeeLogin = '".$_SESSION["UserID"]."'");

$record = db_fetch_array($rs);
$values['EmployeeName'] = $record['EmployeeName'];

$values['Designation'] = $record['Designation'];



Christian, As I added the code but it is not functioning as it should, in both the mentioned fields EmployeeName and Designation the EmployeeLogin name is being logged.
Also the Users details are located in the table called EmployeeDB which have all the details of Employees like EmployeeLogin, EmployeeName and Designation. So how can we get these from the EmployeeDB table related to the EmployeeLogin (Which is a auto user session capture) in the RequestForm.

C
cgphp 6/25/2013

I showed you an example. You have to adjust the query to match your needs.

A
angelcause author 6/25/2013



I showed you an example. You have to adjust the query to match your needs.


Ok can you please tell me that is this query getting the required fields from the table containing the details of the employee.

A
angelcause author 6/25/2013

Thanks Christian I added $_SESSION["UserID"] in both the fields properties and changed them to read only so they worked out.