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
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.......