This topic is locked

dependent table answeres

10/22/2010 10:46:48 AM
PHPRunner General questions
swant author

I have a large database
I have several tables
i have 2 tables that could have the same answer
both table cannot have the same answer so for ex
table 1=4 table 2 cannot =4 but can be another number i cannot figure out how to make these answers dependent on each other. how would i achieve this?
I messed around and can only seem to make it if you put 4 in #1 table then it make #2 table 4 as well and that wont work for my purpose.
Thanks in advance for any advice

Sergey Kornilov admin 10/23/2010

You need to rephrase your question. The following just doesn't make any sense > table 1=4 table 2 cannot =4 but can be another number

swant author 10/25/2010

table 1 can have the same answer as table 2
i want to make it so table 2 cannot have the same answer
so for ex currently if table 1= PIT table 2 can = PIT
I want it so if table 1 = Pit Table 2 You cannot answer it with PIT it would have to be one of the other options in the table



You need to rephrase your question. The following just doesn't make any sense

A
ann 10/26/2010

Hi,
use Before record added/updated event on the Events tab to prevent same answer:

$rs=CustomQuery("select * from table1 where answer='".$values["answer"]."'");

$data=db_fetch_array($rs);

if ($data){

return false;

}

else {

return true;

}



where answer is your actual field name, table1 is your actual table name.

swant author 10/27/2010

Thanks for the help
so i changed it to look like this on the events page in the add page before record was added to look like this
$rs=CustomQuery("select * TABLE1=PIT".$values["PIT"]."'");

$data=db_fetch_array($rs);

if ($data){

return false;

}

else {

return true;

}
so the syntax checks out but it does not work as far as adding it doesnt have any errors and still allows me to add both. I added this to the second table where i did not want to allow the second PIT.
How should i eddit this, im guessing i have things in the wrong spots



Hi,
use Before record added/updated event on the Events tab to prevent same answer:

$rs=CustomQuery("select * from table1 where answer='".$values["answer"]."'");

$data=db_fetch_array($rs);

if ($data){

return false;

}

else {

return true;

}



where answer is your actual field name, table1 is your actual table name.

Sergey Kornilov admin 10/27/2010

I recommend to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.