linking two tables with generated ID

Discussion in 'PHP' started by tldmic, Feb 24, 2010.

  1. #1
    Good day all,

    is it possible to link two tables with a generated userID when submitting registration information,

    say there are two sections in the form

    table 1= P details
    table 2 = L details


    i want to first insert the information into table 1 with a generated ID, then use the generated ID to insert data into table 2,

    any advice

    many thanks
    tldmic
     
    tldmic, Feb 24, 2010 IP
  2. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #2
    If I understood you right, try this
    
    
    " insert into table1 values('', 'value1', 'value2') ";
    where '' is an autoincrement field
    $fid= mysql_insert_id();
    $fid has the value for the '' above
    "insert into table2 values('$fid', 'somevalue') ";
    
    Code (markup):
    If this is not what you wanted, sorry.
    Thanks :)
     
    JEET, Feb 24, 2010 IP