commit
This commit is contained in:
parent
7bb2265517
commit
01b6de5e6f
16
get1.php
16
get1.php
|
@ -1,16 +0,0 @@
|
|||
<?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();
|
||||
?>
|
20
index.html
20
index.html
|
@ -20,24 +20,6 @@
|
|||
}
|
||||
</style>
|
||||
<script>
|
||||
function fetchRoles() {
|
||||
fetch('get1.php')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const select = document.getElementById('select-role');
|
||||
|
||||
data.forEach(role => {
|
||||
const option = document.createElement('option');
|
||||
option.value = role.id;
|
||||
option.textContent = role.role_name;
|
||||
select.appendChild(option);
|
||||
console.log(option);
|
||||
});
|
||||
})
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
fetchRoles();
|
||||
});
|
||||
function fetchClasses() {
|
||||
fetch('get2.php')
|
||||
.then(response => response.json())
|
||||
|
@ -214,6 +196,8 @@
|
|||
<div class="footer-left">
|
||||
<p>B. Hrynowiecki</p>
|
||||
<p>K. Michalak</p>
|
||||
<p>J. Kukiela</p>
|
||||
<p>A. Guzik</p>
|
||||
<p>F. Kowalski</p>
|
||||
<p>S. Ptak</p>
|
||||
<p>B. Bohdan</p>
|
||||
|
|
Loading…
Reference in New Issue