-1
Supposing $this->db
be your Mysqli connection
public function addItemCaja($teste) {
$stmt = $this->db->prepare("INSERT INTO item_juego (id_caja, id_item, cantidad) VALUES (?, ?, ?)");
foreach($teste as $item){
$stmt->bind_param('i', $item['id_caja']); //supondo que id_caja é integer
$stmt->bind_param('i', $item['id_item']); //supondo que id_caja é integer
$stmt->bind_param('i', $item['cantidad']); //supondo que id_caja é integer
$stmt->execute();
}
$stmt->close();
}
Doing this way you also avoid problems with SQL Injection.
Friend, I see you are using the Mysql extension
INSERT INTO 'table' SET ...
, for multiple values you need to use the standard SQL notation that isINSERT INTO 'table' ('col1', 'col2', 'col3') VALUES ('row1val1', 'row1val2', 'row1val3'), ('row2val1', ...) ...
– Israel Merljak
Tiago, I suggest that you never put your code as an image, the training rule is to put it in blocks of code, facilitates understanding and that your question be answered. In its present form it can even be removed by moderation.
– echojn