PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
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);
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"."\n"; } try { $c=$ca->fetch_assoc(); }catch (Exception $e) { echo $e."\n"; }
Show:  
Copy Clear