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
CREATE TABLE table_name ( id INT AUTO_INCREMENT, column_1 INT, column_2 INT, PRIMARY KEY (id) );

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

Copy Clear
Copy Format Clear
<?php $data_list = [ ['specific_key' => 1, 'another_key' => 2], ['specific_key' => 3, 'another_key' => 4], ['specific_key' => 5, 'another_key' => 6], ]; $values = []; $placeholders = []; foreach ($data_list as $row) { $placeholders[] = '(?,?)'; array_push($values, $row['specific_key'], $row['another_key']); } if ($values) { $pdo->prepare( sprintf( 'INSERT INTO `table_name` (`column_1`,`column_2`) VALUES %s', implode(',', $placeholders) ) )->execute($values); } var_export( $pdo->query("SELECT * FROM table_name")->fetchAll(PDO::FETCH_ASSOC) );
Copy Clear