projekt/get1.php

17 lines
341 B
PHP
Raw Normal View History

2024-10-22 12:32:52 +00:00
<?php
$conn = new mysqli("localhost", "root", "", "szkola");
$sql = "SELECT id, role_name FROM roles";
$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();
?>