0
if ($valid) { //insert customer data to customer table
        $pdo = Database::connect();
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = "INSERT INTO signups(FirstName,LastName,Email,Telephone,Address1,Address2,Address3,Zip,Added) values(?, ?, ?, ?, ?, ?, ?, ?, ?)";
        $q = $pdo->prepare($sql);
        $q->execute(array($FirstName,$LastName,$Email,$Telephone,$Address1,$Address2,$Address3,$Zip,$Added));
        $last_id_in=$pdo->lastInsertId();
        //echo $last_id_in;

        // insert product data into product table
        $productName= 'xxxxx';
        $price= '24.00';
        $sql1="INSERT INTO products (AutoID,productName,price) values(:last_id_in,:productName,:price)";
        $r = $pdo->prepare($sql1);
        $r->execute(array(':last_id_in'=>$last_id_in,':productName'=>$productName,':price'=>$price));
        //Database::disconnect();
        //header("refresh:3;url=create1.php");
}   

Hi, i need someone help please. i am working in project that have 2 tables signups, products. i have customer entry and product entry on same page. what i have until done is, creating a customer with Auto ID and getting that Auto ID (last_insert)id) to insert data to product table for that customer. So that i can fetch what produuct ordered by this customer enter image description here if you see, the product is dynamic textfield, so i like to include that in an array. instead of $productname and $price as static. i need array that send multiple rows into table name products. thanks in advance.......

Sebastian Redl
  • 69,373
  • 8
  • 123
  • 157
Selva
  • 60
  • 8
  • possible duplicate of [Inserting multiple rows in mysql](http://stackoverflow.com/questions/6889065/inserting-multiple-rows-in-mysql) – Jay Blanchard Oct 06 '14 at 15:08
  • Hi i looked into other question. But it shows directly entering values in the INSERT statement. can you help me, how its possible dynamic textfields, passing it value to mysql DB through array in PDO? – Selva Oct 06 '14 at 15:14
  • Please do not use "bootstrap" tag, use "twitter-bootstrap" since it means something else – Daniel Cheung Oct 12 '14 at 11:26

0 Answers0