$FIO_author=array(); foreach($_POST['FIO_author'] as $key=>$value){ $FIO_author[] = "('', '$value','".es($_POST['alias'])."')"; } $sql2 = q("INSERT INTO author_book(id_author,FIO,alias) VALUES". implode(',', $FIO_author)); $id_author= DB::_()->insert_id; $sql = q("INSERT INTO book SET id_book = '', date_add = '".es(date('Ymd H:i:s'))."', title_book = '".es($_POST['title_book'])."', annot_book = '".es($_POST['annot_book'])."', descr_book = '".es($_POST['descr_book'])."'"); $id_book= DB::_()->insert_id; $sql3 = q("INSERT INTO book_and_author(id_book,id_author) VALUES('".$id_book."','".$id_author."')"); 

No second id_author is added to the link table.
That is, the first id_author = '249' is added, but the second id_author = 250 is not added to the same id_book = '200' in the link table book_and_author; ps It's about me. And the question is how to add the second id_author to the same id_book?

  • how can you help, if you use some kind of samopisny class to work with the database (why do you need it by the way?) if you have mysqli there then read this comment - zb '29

0