Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
CREATE TABLE events(
id int primary key auto_increment,
event_time timestamp,
event_value int
);
<?php
for ($i=0; $i<3; $i++) {
$dddt = rand(1,15);
$insert_sql = "INSERT INTO events
SELECT MAX(id) + {$dddt}, NOW(), 10 FROM events;";
mysqli_query($mysqli, $insert_sql);
}
// Run query using mysqli
$result = $mysqli->query("SELECT * FROM events");
$rows = $result->fetch_all();
print_r($rows);