Jump to content

Inserting into tables


ainoy31

Recommended Posts

Hello-

 

I have a form that gets filled out and the data is stored in a DB.  I have a question regarding the insert part.  Here is the structure of some of my tables:

 

table: agent

agent_id int(16) NOT NULL auto_increment,

lname varchar(32) NOT NULL,

fname varchar(32) NOT NULL,

middle_initial varchar(32) NULL,

email varchar(32) NOT NULL,

phone varchar(12) NOT NULL,

alt_phone varchar(12) NULL,

PRIMARY KEY (agent_id)

 

table: username_password

user_id int(16) NOT NULL auto_increment,

reg_id int(16) NOT NULL,

agent_id int(16) NOT NULL,

username varchar(32) NOT NULL,

password varchar(32) NOT NULL,

level varchar(32) NULL,

 

PRIMARY KEY (user_id),

FOREIGN KEY (reg_id) REFERENCES register_user (reg_id),

FOREIGN KEY (agent_id) REFERENCES agent (agent_id)

 

table: address

address_id int(16) auto_increment,

agent_id int(16) NOT NULL,

reg_id int(16) NOT NULL,

listing_id int(16) NOT NULL,

street varchar(50) NOT NULL,

city varchar(32) NOT NULL,

state varchar(32) NOT NULL,

zip varchar(16) NOT NULL,

 

PRIMARY KEY (address_id),

FOREIGN KEY (agent_id) REFERENCES agent (agent_id),

FOREIGN KEY (reg_id) REFERENCES register_user (reg_id),

FOREIGN KEY (listing_id) REFERENCES listing (listing_id)

 

I am stuck on the insert logic.  Say I have a form that collects info on a new agent.  I want to make sure that the info gets inserted to the agent table and the address table and finally the username_password table with the agent_id points to the same person on all three tables.  Hope this is clear enough.  Much appreciation.

 

AM

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.