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 works ( id INT AUTO_INCREMENT, type INT(11), description INT(11), hours INT(11), amount INT(11), PRIMARY KEY (id) );

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

Copy Clear
Copy Format Clear
<?php $works = [ 'type' => [1, 5], 'description' => [2, 6], 'hours' => [3, 7], 'amount' => [4, 8] ]; if (!empty($works['type'])) { $sql = "INSERT INTO works (type, description, hours, amount) VALUES (?,?,?,?)"; $stmt = $mysqli->prepare($sql); for ($i = 0, $count = count($works['type']); $i < $count; ++$i) { $stmt->bind_param( "iiii", $works['type'][$i], $works['description'][$i], $works['hours'][$i], $works['amount'][$i] ); $stmt->execute(); } } var_export($mysqli->query("SELECT * FROM works")->fetch_all(MYSQLI_ASSOC));
Copy Clear