Upload files to "/"

This commit is contained in:
amarcel 2024-05-21 08:06:02 +00:00
parent 7b806223be
commit c561c3bb61
4 changed files with 116 additions and 0 deletions

14
fetch.js Normal file
View File

@ -0,0 +1,14 @@
const url = "http://localhost/a1/get.php"
//const url = "http://qstack.pl:8080/z1/get.php"
let lista
fetch(url)
.then(response => response.json())
.then(data => {
sortujSufiksy(data)
});
function sortujSufiksy(data) {
data.forEach((element) => document.querySelector('#nieposortowane').innerHTML += `<li> ${JSON.stringify(element.osoby)} </li>`);
}

17
get.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$dbhost = "qstack.pl";
$dbuser = "boost";
$dbpass = "pass";
$dbname = "db";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$ans = mysqli_query($conn, "SELECT * FROM osoby");
$json = array();
while ($row = mysqli_fetch_assoc($ans)) {
$json[] = $row;
}
echo json_encode($json);
?>

25
index.html Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sortowanie Sufiksów</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h2>Nieposortowane Sufiksy</h2>
<div class="pre" id="nieposortowane"></div>
<h2>Posortowane Sufiksy</h2>
<div class="pre" id="posortowane"></div>
<script src="fetch.js"></script>
<li id="lista">
<ol></ol>
</li>
</body>
</html>

60
styles.css Normal file
View File

@ -0,0 +1,60 @@
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
color: #333;
margin: 0;
padding: 20px;
line-height: 1.6;
}
h1 {
text-align: center;
color: #0056b3;
margin-bottom: 20px;
}
input[type="text"] {
width: calc(100% - 22px);
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #0056b3;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #004494;
}
h2 {
color: #0056b3;
border-bottom: 2px solid #0056b3;
padding-bottom: 5px;
margin-top: 20px;
}
#nieposortowane {
display: flex;
flex-direction: column;
}
/* .pre {
background-color: #fff;
border: 1px solid #ccc;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
} */