title: How to insert multiple MySQL table rows from a PHP array
body: <p>I'm new to both PHP and MySQL and I have a pretty complicated task to do for my current know-how. It goes like this:</p>
  
  <p>I'm trying to create a data-driven website with a hand made CMS that will allow a user with no knowledge of web design/web development to manage it. Where I'm stuck is when I try to create a query to handle the data inserted to the database. It is a bookstore and I'm inserting books in the database. I thought of creating 3 tables, one to store the books themselves, one to store the categories these books belong to (f.e. literature, mystery, fantasy, etc) and, since the relation between these two tables is many-to-many relationship, I also created a lookup table to link these two, using 2 columns populated with 2 foreign keys representing the IDs of the two tables. </p>
  
  <p>The problem is I can't find how to insert multiple rows with same ID (the book ID) on one column and different second column (the category ID). The categories will be picked in an HTML form via checkboxes. I' ve seen in several posts here I need to make an array in PHP script to store the data from the checkboxes the user picked, but I have absolutely no clue on how to structure the query that will turn these checkboxes into multiple MySQL table rows.</p>
  
  <p>I've seen people suggesting imploding the values, but that would store multiple values in one row, or am I mistaken? Because that is not what I want, I want (if f.e. the user checked 3 categories checkboxes) to create 3 rows in the lookup table.</p>
  
  <p>Thanks in advance for your time seeing my question.</p>