Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Insterting into more than one table help

    So, I was looking online and really couldnt find help how to insert data from a form into different tables.

    Example: I want to insert lets say the number 100 into the tables:

    drivers:, Sales: and into the sales column in both. If this makes sense than can I get a general idea, I dont need someone to write it all out for me, lol unless you really want to ! Anyways I would appreciate the help! Cheers!

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    You would simply write more than one SQL statement in your processing script.

    PHP Code:
    //this is pseudo code and you should always validate user input.
    $sql "INSERT INTO drivers (`sales`) VALUES ('$_POST['somefield']')";
    $mysql_query($sql) or die(mysql_error());

    $sql "INSERT INTO sales (`sales`) VALUES ('$_POST['somefield']')";
    $mysql_query($sql) or die(mysql_error()); 
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •