Compare commits

..

2 Commits

Author SHA1 Message Date
piotrb 65c5b61829 merge 2024-05-20 12:08:44 +02:00
piotrb bdda7e717f i 2024-05-20 11:38:56 +02:00
4 changed files with 63 additions and 1 deletions

View File

@ -1,9 +1,13 @@
const url = "http://localhost/p20/get.php"
<<<<<<< HEAD
let lista
=======
>>>>>>> dev2
fetch(url)
.then(response => response.json())
.then(data => {
<<<<<<< HEAD
// console.log(data)
sortujSufiksy(data)
})
@ -25,4 +29,25 @@ function sortujSufiksy(data) {
function formatSufiksy(sufiksy) {
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
=======
sortujSufiksy(data)
});
function sortujSufiksy(data) {
const slowo = document.getElementById('slowo').value;
// console.log("tetst" + slowo)
const sufiksy = [];
for (let i = 0; i < slowo.length; i++) {
sufiksy.push(slowo.slice(i));
}
data.forEach((element) => document.querySelector('#nieposortowane').innerHTML += `<li> ${JSON.stringify(element.osoby)} </li>`);
// console.log(formatSufiksy(sufiksy));
// sufiksy.sort();
// document.querySelector('#posortowane').innerHTML += formatSufiksy(sufiksy);
}
function formatSufiksy(sufiksy) {
// console.log(sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n'));
>>>>>>> dev2
}

View File

@ -14,9 +14,15 @@
<input type="text" id="slowo" placeholder="Podaj słowo">
<button onclick="sortujSufiksy()">Sortuj Sufiksy</button>
<h2>Nieposortowane Sufiksy</h2>
<<<<<<< HEAD
<pre id="nieposortowane"></pre>
<h2>Posortowane Sufiksy</h2>
<pre id="posortowane"></pre>
=======
<div class="pre" id="nieposortowane"></div>
<h2>Posortowane Sufiksy</h2>
<div class="pre" id="posortowane"></div>
>>>>>>> dev2
<script src="fetch.js"></script>
<li id="lista">

17
qstack.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$dbhost = "qstack.pl";
$dbuser = "root";
$dbpass = "";
$dbname = "osoby";
$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);
?>

View File

@ -45,10 +45,24 @@ h2 {
margin-top: 20px;
}
<<<<<<< HEAD
pre {
=======
#nieposortowane {
display: flex;
flex-direction: column;
}
/* .pre {
>>>>>>> dev2
background-color: #fff;
border: 1px solid #ccc;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
<<<<<<< HEAD
}
=======
} */
>>>>>>> dev2