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 users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100)
);
INSERT INTO users (name) VALUES ('Alice'), ('Bob'), ('Charlie');
<?php
<!DOCTYPE html>
<html>
<head><title>Simple PHP & SQL</title></head>
<body>
<h1>User List</h1>
<?php
// Use the predefined $mysqli connection provided by PHPize
$result = $mysqli->query("SELECT name FROM users");
while($row = $result->fetch_assoc()) {
echo "<p>" . htmlspecialchars($row['name']) . "</p>";
}
?>
</body>
</html>