S
S
Sergey Konev2022-02-07 21:14:50
PHP
Sergey Konev, 2022-02-07 21:14:50

How to write received data to php+sq database?

I use the checkbox method to select the necessary positions from the table (No. 1) by id (there can be any number of them) and send the id data using the post method to the php handler, I get the data in the array $id = $_POST['id'];

And here's the question? how can I write the resulting array from the id of table No. 1 into a column in table No. 2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2022-02-07
@FanatPHP

$stmt = $mysqli->prepare("INSERT INTO table (id1, id2) VALUES (?,?)");
$id1 = 1;
foreach( $_POST['id'] as $id2);
    $stmt->bind_param("ss", $id1, $id2);
    $stmt->execute();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question