<?php $table = 'test'; $tableNames= array('col1' => 'str', 'col2' => 3, 'col4' => 5.5); $query = "INSERT INTO $table ("; $query .= implode(', ', array_keys($tableNames)); $query .= ") VALUES ("; $query .= str_repeat('?, ', count($tableNames) - 1); $query .= "?)"; echo $query; $types = str_repeat('s', count($tableNames)); $stmt->bind_param($types, ...$tableNames);
You have javascript disabled. You will not be able to edit any code.