This topic is locked

multiple key fields

10/14/2009 6:17:57 PM
PHPRunner General questions
S
specpa author

tableA

ID_A

Values_A
TableB

ID_B

Values_B
TableC

Values_A (LOV)

Values_B (LOV)

Code
the combination of Values_A and Values_B has to be unique, for example

Values _A Values_B

1 2 (ok)

1 3 (ok)

2 1 (ok)

1 2 (not ok)
The code is a unique field
Users want to select Values_A and Values_B from a list, and get as an additional value the corresponding Code value
How to set this up in phprunner?

M
meirco 10/15/2009



tableA

ID_A

Values_A
TableB

ID_B

Values_B
TableC

Values_A (LOV)

Values_B (LOV)

Code
the combination of Values_A and Values_B has to be unique, for example

Values _A Values_B

1 2 (ok)

1 3 (ok)

2 1 (ok)

1 2 (not ok)
The code is a unique field
Users want to select Values_A and Values_B from a list, and get as an additional value the corresponding Code value
How to set this up in phprunner?



Hi I just started using PHPRunner but had the same situation in the project I am working on.
look at the dependency option tutorial http://www.xlinesoft.com/tutorials/dependentdropdowns.htm

Tutorial
Meir

S
specpa author 10/15/2009



Hi I just started using PHPRunner but had the same situation in the project I am working on.
look at the dependency option tutorial http://www.xlinesoft.com/tutorials/dependentdropdowns.htm

Tutorial
Meir


I know how dependant LOVs work.

In my situation first each combination of Values _A Values_B has to be unique. I dont know how to achieve this.

In an extra table a user selects from LOVs "Value_A" (not the keyfield) and "Value_B" (not the keyfield) and gets as result "Code". I dont know how to set this up. See sample below.
username, date, chosen Value_A, chosen Value_B, result code (read only)

J
Jane 10/15/2009

Hi,
you can check entered values in the Before record added event and show error message if needed.

Here is a sample:

global $dal;

$rstmp = $dal->TableC->Query("Values_A='".$values["Values_A"]."' and Values_B='".$values["Values_B"]."'","");

if ($datatmp = db_fetch_array($rstmp))

{

//duplicate values

$message = "Duplicate values. Please select another one.";

return false;

}

return true;
S
specpa author 10/15/2009



Hi,
you can check entered values in the Before record added event and show error message if needed.

Here is a sample:

global $dal;

$rstmp = $dal->TableC->Query("Values_A='".$values["Values_A"]."' and Values_B='".$values["Values_B"]."'","");

if ($datatmp = db_fetch_array($rstmp))

{

//duplicate values

$message = "Duplicate values. Please select another one.";

return false;

}

return true;



thanks, this works fine!
I can't get the second part of my question working

In an extra table a user selects from LOVs "Value_A" (not the keyfield) and "Value_B" (not the keyfield) and should get as result "Code". I dont know how to get the result field. See sample below.
username, date, chosen Value_A, chosen Value_B, result code (read only)

I prbalbly will have to put some cosde into after record added

J
Jane 10/16/2009

Hi,
use this code in the Before record added event:

$values["Code"] = $values["Values_A"].$values["values_B"];

S
specpa author 10/16/2009



Hi,
use this code in the Before record added event:

$values["Code"] = $values["Values_A"].$values["values_B"];


Thanx, the principle works, but I would like to obtain the values from TableC, while inputting data in table D

(table D: username, date, chosen Value_A, chosen Value_B, result code (read only))

desired workflow

user fills in table D ValueA and ValueB

with script: find in tableC the corresponding Values_A and Values_B and output the corresponding Code value in table D

J
Jane 10/16/2009

Hi,
you need to select Code from TableC based on the Values_A and Values_C and save it in the TableD. Use Before record added event for this purpose.

global $dal;

$rstmp = $dal->TableC->Query("Values_A='".$values["Values_A"]."' and Values_B='".$values["Values_B"]."'","");

$values["Code"] = $data["Code"];
S
specpa author 10/16/2009



Hi,
you need to select Code from TableC based on the Values_A and Values_C and save it in the TableD. Use Before record added event for this purpose.

global $dal;

$rstmp = $dal->TableC->Query("Values_A='".$values["Values_A"]."' and Values_B='".$values["Values_B"]."'","");

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



the $data variable is not recognized

error 8, undefined variable data

J
Jane 10/19/2009

Hi,
sorry for my fault.

Here is the correct one:

global $dal;

$rstmp = $dal->TableC->Query("Values_A='".$values["Values_A"]."' and Values_B='".$values["Values_B"]."'","");

$data = db_fetch_array($rstmp);

$values["Code"] = $data["Code"];
S
specpa author 10/20/2009



Hi,
sorry for my fault.

Here is the correct one:

global $dal;

$rstmp = $dal->TableC->Query("Values_A='".$values["Values_A"]."' and Values_B='".$values["Values_B"]."'","");

$data = db_fetch_array($rstmp);

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




echo $values["Code"] gives the correct value but this value isnt filled in in the field,

do I need an extra command to accomplish this?

J
Jane 10/21/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

S
specpa author 10/21/2009



It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.



I uploaded to the demo account, at the demoaccount it works fine.

Looked into my mysql and corrected dataset types and lenght, it works now.

thanx!