Panos
asked on
After insert pass the value from the primary key in session to the next page
Hello experts.
I have a table with 3 columns
art_ID (primary key)
test1
test2
Now with a query:
<cfquery datasource=#dsn#>
INSERT into test1,test2
VALUES ('#form.test1#','#form.tes t2#')
</cfquery>
<cflocation url="Detail.cfm">.
To get the values in the detailpage i need to get the art_ID value from the that insert
I have a table with 3 columns
art_ID (primary key)
test1
test2
Now with a query:
<cfquery datasource=#dsn#>
INSERT into test1,test2
VALUES ('#form.test1#','#form.tes
</cfquery>
<cflocation url="Detail.cfm">.
To get the values in the detailpage i need to get the art_ID value from the that insert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, when i said "developing a component," I meant a component that other developers could use... something you would post for download for instance that has to be DB independent.
ASKER
Is this working in MySQL too.
Can i make the insert, and on the same page get the art_id that was generated and than pass this with a session to the next page?
Can i make the insert, and on the same page get the art_id that was generated and than pass this with a session to the next page?
ASKER
Thank you for your help.
regards
Panos
regards
Panos
the full code for mySQL would be (note the last line of the cfquery):
<cfquery name="insertTest" datasource=#dsn#>
INSERT into test1,test2
VALUES ('#form.test1#','#form.tes t2#');
SELECT last_insert_id() AS newID
</cfquery>
then you would do:
<cfset session.variableName = insertTest.newID />
if you wanted it in a session.
<cfquery name="insertTest" datasource=#dsn#>
INSERT into test1,test2
VALUES ('#form.test1#','#form.tes
SELECT last_insert_id() AS newID
</cfquery>
then you would do:
<cfset session.variableName = insertTest.newID />
if you wanted it in a session.