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!!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.