$array = array(10, 25, 7, 89, 100) ; // This is your array of IDs
$sql = $db->prepare("INSERT INTO selected (selected_customer) VALUES (:param_id)") ; // Prepare the INSERT
foreach($array as $id) { // Iterate through the array
$sql->execute([':param_id' => $id) ; // Execute for each ID
}
I don’t know the context in which this will be used. I counted only 5 ID values in your example. Will thousands be inserted in one run of the script?
You can make multiple inserts in a single query:-
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of comma-separated column values, with lists enclosed within parentheses and separated by commas. Example: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9); https://dev.mysql.com/doc/refman/5.5/en/insert.html