Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $data = [ range(1,3), range(4,6), range(7,9), ]; $sql = "INSERT INTO testTable (col1,col2,col3) VALUES "; $values = "(?".str_repeat(",?",count($data[0])-1).")"; // (?,?,?) $sql . = $values.str_repeat(",$values",count($data)-1); echo $sql; $statement = $mysqli->prepare($sql); $types = str_repeat("s", count($data) * count($data[0])); $params = array_merge(...$data); $statement->bind_param($types, ...$params); $statement->execute();
Copy Clear