Hi! Could we please enable some services and cookies to improve your experience and our website?
No, thanks.
Okay!
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
CREATE TABLE City (
Name VARCHAR(64),
District VARCHAR(64)
);
INSERT INTO City VALUES
('Aachen', 'Nordrhein-Westfalen'),
('Augsburg', 'Baijeri'),
('Bergisch Gladbach', 'Nordrhein-Westfalen'),
('Berlin', 'Berliini'),
('Bielefeld', 'Nordrhein-Westfalen');
SQL Server:
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
MySQL 9.3.0
MariaDB 11.4
MariaDB 11.8
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
PostgreSQL 16
PostgreSQL 17 + PostGIS
PostgreSQL 17 + PostGIS WorkShop (ReadOnly)
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
RedDatabase 5.0
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
ClickHouse
Run SQL code
Save snippet
ER Diagram
<?php
//https://dev.to/rozhnev/new-in-php-82-mysqliexecutequery-mysqliexecutequery-4g2h
//https://phpize.online/sql/mysql57/aa112b7fe80016d72860c6346cd2a3e6/php/php82/8975cd8ea679e87b07fd99d23f885b3c
//https://stackoverflow.com/questions/14624509/single-result-from-database-using-mysqli
$a = "Aachen";
$b = "nordrhein-Westfalen";
//$query = "SELECT * FROM City WHERE Name=? AND District=? ORDER BY Name LIMIT 5";
//$data = $mysqli->execute_query($query, [$a, $b]);
$data = mysqli_query($query, [$a, $b]);
//$data = mysqli_query($query, "SELECT * FROM City WHERE Name = 'Aachen' ORDER BY NAME LIMIT 5");
$num_rows = mysqli_num_rows($data);
echo "num_rows: " . $num_rows . "\n";
//single result
$row = mysqli_fetch_assoc($data);
$name = $row['Name'];
echo $name . "\n";
echo "Result set has " . $num_rows . " rows\n";
printf("Result set has %d rows.\n", $num_rows);
foreach ($data as $row) {
//printf("%s \n", $row["Name"]);
$name = $row["Name"];
$district = $row['District'];
echo $name . "\n";
echo $district . "\n";
}
PHP version :
PHP 7.4
PHP 8.0
PHP 8.1
PHP 8.2
PHP 8.3
PHP 8.4
Run PHP Code
Save snippet