This topic is locked

Depency

10/7/2010 2:01:03 PM
PHPRunner General questions
W
Wimer author

Problem:

I have a 2 tables, tableA and tableB.
TableA have 3 fields
Afield1 (dropdown list)

Afield2

Afield3
TableB have 2 fields

Bfield1

Bfield2
When choosing something from the dropdownlist, I like to add value to Afield2 depending of the choice in Afield1. The values are stored in TableB. (I use the lookup wizard here).
After that I want to search for the record with highest number based on the value in Afield2. Then I want to take this number, add it with 1, and put the result in Afield3.
I know this is easy for many of you, but not for me.
Thanks in advance!

Sergey Kornilov admin 10/7/2010

I wasn't able to decipher that. Do you have another way of explaining what you trying to build?

W
Wimer author 10/8/2010



I wasn't able to decipher that. Do you have another way of explaining what you trying to build?


Hello,

Its not easy to explain my thinking in another language, but I'll give it a try.

I have a database where I store pictures, which I built for about 3 years ago. Now I wanna make some changes so I can put the pictures in different categories. I want to store categories in a separate table (Category), with two fields, categoryID and categoryNAME.
On the addpage in the main table, the first thing I want to do is choose category from a dropdown list.(lookup in Category)

Depending on the choice, the two next fields will get their values.

The first of these two fields,signature, will get the value from Category(categoryNAME).

The second field, number, will hold the value of (the highest number added so far in that category + 1).
How do I get this number? And how did I put it into the number field?

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=53398&image=1&table=forumreplies' class='bbc_emoticon' alt=':huh:' />

Sergey Kornilov admin 10/8/2010

I guess I see what you saying. Auto-populating the second field, signature, is easy. PHPRunner 5.3 added a new Autofill feature that does exactly that.
Calculating the next available number in selected category is more complicated because it needs to be run on the server side. Your best bet is to create a BeforeAdd event and calculate this number there.

W
Wimer author 10/10/2010



I guess I see what you saying. Auto-populating the second field, signature, is easy. PHPRunner 5.3 added a new Autofill feature that does exactly that.
Calculating the next available number in selected category is more complicated because it needs to be run on the server side. Your best bet is to create a BeforeAdd event and calculate this number there.


Hi!

Great. The Autofill feature was exactly what I needed. So far so good. The next issue is to calculate next available number. What if I could take the value of one of the autofilled fields, and use that in a search, e.g.
$rsfoto = mysql_query("SELECT max(Tilvekstnummer) FROM Bilder WHERE '$_POST['Signatur']'",$conn);

$fotodata = mysql_fetch_array($rsfoto, MYSQL_NUM);

$f = $fotodata[0]+1;

$_SESSION["Tilvekstnummer"] = $f;
I have tried, but got these error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in .........../include/......_events.php on line 285
Some ideas?

Sergey Kornilov admin 10/10/2010

Do not use $_POST['Signatur']. Check events documentation that explains how to access field values. Most probably you need to use $values['Signatur']

W
Wimer author 10/14/2010



Do not use $_POST['Signatur']. Check events documentation that explains how to access field values. Most probably you need to use $values['Signatur']


Have tried $values, but get the error: Undefined variable: values

Sergey Kornilov admin 10/14/2010

You might be using wrong event for this purpose (one where $values array is not accessible).
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.

W
Wimer author 10/31/2010



You might be using wrong event for this purpose (one where $values array is not accessible).
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.


I have uploaded the project to my demoaccount.

Sergey Kornilov admin 10/31/2010

Make sure you open a ticket at http://support.xlinesoft.com sending your project URL as well.