17 lines
344 B
PHP
17 lines
344 B
PHP
|
<?php
|
||
|
$conn = new mysqli("localhost", "root", "", "szkola");
|
||
|
$sql = "SELECT id, class_name FROM classes";
|
||
|
$result = $conn->query($sql);
|
||
|
|
||
|
$roles = [];
|
||
|
if ($result->num_rows > 0) {
|
||
|
while ($row = $result->fetch_assoc()) {
|
||
|
$roles[] = $row;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
header('Content-Type: application/json');
|
||
|
echo json_encode($roles);
|
||
|
$conn->close();
|
||
|
?>
|