CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 insert into two table

Print topic Send  topic

Author Message
yana

Posts: 11
Posted: 08/07/2007, 6:06 PM

hi...

just a simple question but it makes me crazy.

I have a form which have name and age. Once user submit the form, the unique id will auto-generated for them.

The problem is, I'm using multistep registration and want to send the id value into another table for other purpose. My idea is to use mysql query by insert value into two tables but don't really know where should I put the code and how to do it :-/.

Hope anyone can help me.

Thanks in advance.
View profile  Send private message
ckroon

Posts: 869
Posted: 08/07/2007, 8:21 PM

Pass the ID using a link.
Create your "Next Step" link and indicate your nextpage.php in the Static Address box. Hit OK. Now click the link and look in the Data section. CLick the ... to the right of Href Source, go to Parameters. There, indicate the ID field as the Parameter Source and ID as the Parameter Name. Leave it as Type-URL.

Build your nextpage.php with a grid on it and in the Where statement put where ID=ID.

You will have to put a hidden field on that page with ID as the source, and give it a CCGetFromGet("ID", "") as its default value.

You may also want to Google "MYSQL Foreign keys", depending on what data you are saving and how it is updating.

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
yana

Posts: 11
Posted: 08/07/2007, 8:59 PM

what if i use record builder to create the nextpage.php since I have two forms

- form a which connected to table a
- form b which connected to table b

I want to submit the unique id in table a into table b as a referral.
View profile  Send private message
yana

Posts: 11
Posted: 08/08/2007, 12:36 AM

and also, i'm using button in this form to go to the next page...

anyone...have idea?
View profile  Send private message
Koren

Posts: 83
Posted: 08/08/2007, 7:04 AM

Download the Example Files; use > MULTI STEP REGISTRATION.
You will find:
Programming Notes
The Record form's After Insert event is used to retrieve the last inserted key (user_id) after the user record is created. The key is then passed to the next page as a URL parameter.

Use (alter to suit your tables) the code found in the forms After Insert Event.
View profile  Send private message
Wkempees
Posted: 08/08/2007, 7:08 AM

The proper procedure (globally described) is:

User in From A, submits.
Form A does the INSERT into table a generating a unique autonum ID.
In the From A event AfterInsert, you query the last_inserted_id() and
that you pass either by URL or by Session variable to Form B.
Form B retreives the URL or Session variable and uses that in it's own SQL.

Using the "Search" menu option in this Forums top menu, search for
"last insert id" (my favourite:
http://forums.codecharge.com/posts.php?post_id=82037&s_...=last+insert+id

OR
MySQL docs for last_insert_id()

Walter

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.