Jump to content

INSERT into multiple tables please help (php)


JonnySnip3r

Recommended Posts

Hey guys i have been making a website and i have hit a road block and hope someone can please help. Ok i have been making a signup page eassy however i have incorporated a messaging system into my website i have 2 tables so far one named members and one named pmessage (where the personal messages are held) the way i associate these tables with one another is in my pmessage i have a column named member_id which matched the id in the members table (hope this seems ok only way i couldt think) now i have a problem here is my sql code when a member registers.

 

$register = mysql_query("INSERT INTO members (id,username,password,firstname,lastname,location,aboutme,profilepicture,age,private) VALUES ('','$username','$password','','','','','','','')");

 

as you can see i insert username and password everything else is null they can full this out in the profile area (hope this seems ok) i am pretty new to php. anyways how would i go about inserting whatever auto incremented id from the members table into the non auto increment member_id in the pmessages table? hope i explained that ok. anyways if i was to do it separately here is the code for that.

 

$register_pmessages = mysql_query("INSERT INTO pmessages (id,member_id,title,message) VALUES ('','','','')");

 

really hope someone can help, and thanks!!

 

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.