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 clients (id int); insert into clients values (1),(2); create table client_2_data (id int); create table client_1_data (id int, `updated` datetime DEFAULT NULL);

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

Copy Clear
Copy Format Clear
<?php $ca=$mysqli->query('SELECT * FROM `clients`'); $c=$ca->fetch_assoc(); try { $mysqli->query('ALTER TABLE `client_'.$c['id'].'_data` ADD COLUMN `updated` datetime DEFAULT NULL'); }catch (Exception $e) { echo "Caught for {$c['id']}\n $e"; } $c=$ca->fetch_assoc();
Copy Clear