I can not understand what is missing in the code, I need to copy a few lines from the table based on the selected checkbox , I have a checkbox array called abs to process the data. Here is the php copy code. I will explain the condition, if the copypast button is pressed and the checkbox selected in the abs array, the condition is met, the rows in the table are copied, I cannot connect the abs checkbox to the abs checkbox array
if (isset($_POST['copypast']) and(!empty($_POST['abs']))) { $id = $_POST['id']; $result = $dbh - > query("SELECT * FROM tovars WHERE id=$id") - > fetch(); $result['flag'] = 0; $result['id'] = 0; foreach($result as $k = > $v) { $fields[] = $k; $vals[] = "'$v'"; } $fields1 = implode(", ", $fields); $vals1 = implode(", ", $vals); $q = "INSERT INTO tovars (".$fields1. ") VALUES (".$vals1. ")"; $query = $dbh - > prepare($q); $query - > execute(); } else { echo "не работает"; } the form with the table is http://jsfiddle.net/gxpfo5j8/
I didn’t add, when copying several lines these lines should be inserted into the table, the above code only works if for example there is a button on each line and when I click on it one line will be copied, but I need to copy several lines. Tell me how you can implement