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 city (
id int primary key,
name varchar(64)
);
INSERT INTO city VALUES (1, 'Moscow'), (2, 'St. Pitersburg');
<?php
$connect = &$mysqli;
$citys = mysqli_query($connect, "SELECT * FROM `city`");
$citys = mysqli_fetch_all($citys);
echo '<select name="magaz">' . PHP_EOL;
foreach ($citys as $city) {
echo '<option value=' . $city[0] . '>' . $city[1] . '</option>' . PHP_EOL;
}
echo '</select>' . PHP_EOL;