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 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'); SELECT * from City

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

Copy Clear
Copy Format Clear
<?php $query = 'SELECT Name FROM City WHERE District=? ORDER BY Name LIMIT 5'; $result = $mysqli->execute_query($query, ['Nordrhein']); if ($result->num_rows > 0) { foreach ($result as $row) { printf("%s \n", $row["Name"]); } } else { echo 'Data not found'; }
Copy Clear