how to insert records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ddtpmyra
    Contributor
    • Jun 2008
    • 333

    how to insert records

    I dont know if this a PHP or MYSQL question but im pretty sure its the combination of two.

    My problem is how to insert my multiple variable to mysql table in one colum.

    example var
    $name1
    $name2
    $name3

    employee: column names
    id name date

    PHP query
    Code:
          $query = "insert into employee (id, name, date) values ('{$id}','{$name1}',now())";
    my problem is how to execute the query one time to insert the above 3 variables to the table?
  • hoopy
    New Member
    • Feb 2009
    • 88

    #2
    Hi something like this:

    Code:
    mysql_query
    (" 
      INSERT INTO table (field1, field2) 
      VALUES
      ('$var1', UNIX_TIMESTAMP()), 
      ('$var2', UNIX_TIMESTAMP())
    ");
    That would insert 2 records in one statement.

    Cheers.

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),( 4,5,6),(7,8,9);

      Comment

      • ddtpmyra
        Contributor
        • Jun 2008
        • 333

        #4
        Grazie! Hoopy and Hriat

        Comment

        • prabirchoudhury
          New Member
          • May 2009
          • 162

          #5
          have a look on some good tutorials on php and mysql tutorial

          Comment

          Working...