J
|
Jane 6/2/2008 |
Hi, |
V
|
vytb author 6/2/2008 |
Hi, you can increase value of this field in the Before record added event on the Events tab for detail table. Also you can set up primary key in the detail field as auto-increment in the database directly. There is only one restriction. You can't use auto-increment field as foreign key in the detail table.
|
J
|
Jane 6/4/2008 |
Hi, global $conn; $rs = db_query("select max(FieldName) from TableName", $conn); $data = db_fetch_numarray($rs); $new_value = $data[0]+1; |
V
|
vytb author 6/4/2008 |
Hi, here is a sample:
|
J
|
Jane 6/4/2008 |
Hi, ... if ($data) $new_value = $data[0]+1; else $new_data = 1; |
V
|
vytb author 6/4/2008 |
Hi, you need to replace TableName with your actual table name. Also you can check max value in your code:
|
J
|
Jane 6/5/2008 |
It's difficult to tell you what's happening without seeing actual files. |
V
|
vytb author 6/6/2008 |
It's difficult to tell you what's happening without seeing actual files. Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error. I'll find what's wrong with your project inspecting it at Demo account site.
|
T
|
thomaso 3/28/2009 |
I am trying to do the same thing with a Sequence column. What I don't see from the code sample is how $new_data is assigned to a column. Also to make the value visible in the Sequence column, in my case, to the user. How would that be done? One other thing, I am doing this using In-Line add. |
V
|
vytb author 3/28/2009 |
I am trying to do the same thing with a Sequence column. What I don't see from the code sample is how $new_data is assigned to a column. Also to make the value visible in the Sequence column, in my case, to the user. How would that be done? One other thing, I am doing this using In-Line add. Thanks!
|
T
|
thomaso 3/28/2009 |
If you think that the case is similar, your 'Sequence' is the 'test' in the code sample. Moreover, other variables could be needed, like in 'where' or else. Concerning, visibility to the user, I may not understand your issue - this value is not hidden, usually 'readonly' only...
|
V
|
vytb author 3/28/2009 |
Please forgive me for my confusing statement about about the value being visible. I would like the new incremented value to be placed in the forms 'Sequence' field when the user clicks on the InLine Add button/link. As far as the 'test' goes, that is the field name from the original code, if I understand you correctly. I still do not see how "$new_value = $data[0]+1;" or "$new_data = 1;" knows which field to assign itself to. In my case I want the $new_value or $new_data to be assigned to the 'Sequence' field in my table and on the form field. All this to say, I have been programming for a long time, but am new to PHP. I may be missing something in the syntax.
|
T
|
thomaso 3/28/2009 |
Thanks, vitas, for your help. |
T
|
thomaso 3/28/2009 |
Ok, after doing a lot more research, guessing, and such, I got it to work (for me at least). global $data, $conn, $control_Sequence, $control_SectionQuestionID;
|