Thread: Table data

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    26
    Rep Power
    0
    Hello all,

    I have been reading the mysql manual regarding data insertion into a table, but it does not have any reference for inserting individual data into seperate tables. Is the following the correct way of doing it?
    I have tested it and it works, but is there a more efficient method? I hope to include 6 more tables in the code below.
    Any ideas would be appreciated.

    Regards

    Richard

    <html>
    <head>
    <title>signup form</title>


    <body bgcolor="#FF9933">
    <?
    /* This php3.0 script will provide the sign up form processing.
    */

    $con=mysql_connect('hostname','username','password');

    //make connection to the database

    mysql_select_db('wayhawke_com',$con);
    //Inserting data into contact database..

    $result=mysql_query("INSERT INTO contact (first_name, last_name, email, address, suburb, home_phone, fax, verify, verify_a) VALUES ('$first_name', '$last_name', '$email', '$address', '$suburb', '$home_phone', '$fax', '$verify', '$verify_a')",$con);
    //issue your insert query..


    // Inserting user data into user database..
    $result=mysql_query("INSERT INTO user (login, passw) VALUES ('$login', '$passw')",$con);


    // Inserting user data into headline database..
    $result=mysql_query("INSERT INTO headline (headlines) VALUES ('$news $sport')",$con);


    if (mysql_affected_rows($result) == 1){
    //updated the database..

    echo "HELLO, $first_name $last_namen";
    echo "Your info has been entered into our databasen";
    }else{
    //couldn't update database..

    echo "Error !! while insertionn";
    exit;
    }
    ?>

    //----------------------------------------

    ?>

    <p>&nbsp;</p>
    <p>&nbsp;</p>
    </body>
    </html>
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,645
    Rep Power
    4492
    I don't think there is any way to combine insert statements across tables. someone please correct me if i'm wrong, because i could use something like that, too.

    ---John Holmes...

Similar Threads

  1. Javascript - dynamically SHOW/HIDE table data
    By chinacat456 in forum JavaScript Development
    Replies: 1
    Last Post: December 16th, 2003, 01:56 PM
  2. paginating data w/ inner table joins
    By neo100101 in forum PHP Development
    Replies: 5
    Last Post: November 19th, 2003, 05:36 AM
  3. archiving data into another table
    By muinujnik in forum MySQL Help
    Replies: 0
    Last Post: November 15th, 2003, 08:18 PM
  4. Replies: 0
    Last Post: June 20th, 2002, 03:12 PM
  5. create a data entry HTML form for given table
    By hayden in forum PHP Development
    Replies: 5
    Last Post: September 25th, 2001, 10:29 AM

IMN logo majestic logo threadwatch logo seochat tools logo