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");
}
嗨,我需要有人帮忙。我在项目中工作,有2个表注册,产品。我在同一页面上有客户输入和产品输入。我所做的就是创建一个具有自动ID的客户并获取该自动ID(last_insert)id)以将数据插入该客户的产品表。这样我就可以获取该客户订购的产品 如果你看,产品是动态文本字段,所以我想将它包含在一个数组中。而不是$ productname和$ price作为静态。我需要将多行发送到表名产品的数组。 提前谢谢.......