我有一个原始的和4个克隆的书行详细信息,
我已经使用pdo将第一行插入数据库但是我不知道如何使用循环插入克隆的行。
我用过的代码是,
$books_booktitle = $_POST['booktitle'];
$books_bookgenre = $_POST['bookgenre'];
$books_bookwriter = $_POST['bookwriter'];
$books_bookdescription = $_POST['bookdescription'];
$books_userid = $db->lastInsertId();
$stmt = $db->prepare("INSERT INTO bookdetails (BookTitle,BookGenre,BookWriter,BookDescription,UserId) VALUES (:BookTitle, :BookGenre, :BookWriter, :BookDescription, :UserId)");
$stmt->bindParam(':BookTitle', $books_booktitle);
$stmt->bindParam(':BookGenre', $books_bookgenre);
$stmt->bindParam(':BookWriter', $books_bookwriter);
$stmt->bindParam(':BookDescription', $books_bookdescription);
$stmt->bindParam(':UserId', $books_userid);
$stmt->execute();
如果您有任何想法,请回复。
答案 0 :(得分:0)
也许这会对你有所帮助
for ($i = 0; $i < 5; $i++) {
$stmt = $db->prepare(...);
...
$stmt->execute();
}