PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

PHPize.online is a free online environment for quickly running, experimenting with and sharing PHP (including Carbon extension for DateTime) and SQL code. You can run your SQL code with PHP code that can use the same DB. For database manipulations you can use pre-defined instances of PDO ($pdo), mysqli ($mysqli) & Laravel query builder ($db)

Copy Format Clear
create table products ( id int primary key auto_increment, product varchar(64), color varchar(16) ); insert into products(product, color) values ('t-shirt', 'red'), ('sweater', 'blue'), ('t-shirt', 'green'), ('sweater', 'yellow'), ('t-shirt', 'purple'), ('sweater', 'indigo'), ('t-shirt', 'black');
Copy Clear
Copy Format Clear
<?php $product = 'sweater'; $query = "select distinct color from products where product = ?;"; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute([$product]); $colors = $stmt->fetchAll(PDO::FETCH_ASSOC); print_r($colors);
Show:  
Copy Clear