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 if not exists users
(
user_id int primary key auto_increment,
user_name varchar(255) not null,
user_age int,
user_bio varchar(255)
);
INSERT into users (user_name, user_age, user_bio) values
('Andrew', 23, 'Artist'),
('Matthew', 19, 'Student'),
('Alex', 24, 'Accountant');
SELECT * FROM users
<?php
use Carbon\Carbon;
$now = Carbon::now()->format('d/m/Y');
printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion());
$query = "SELECT VERSION() as version;";
// Run query using mysqli
$result = $mysqli->query($query);
$version = $result->fetch_object();
printf('DB version (mysqli): %s ' . PHP_EOL, $version->version);
$sql = 'SELECT * FROM users';
$result = $mysqli->query($sql);
while ($row = mysqli_fetch_array($result)){
print ("\nName: " . $row['user_name'] . ' | Age: ' . $row['user_age'] . ' | Bio: ' . $row['user_bio']);
}