dane przekazane do funkcji

This commit is contained in:
piotrb 2024-05-20 10:32:10 +02:00
parent 24dc33d4cf
commit e527916149
3 changed files with 23 additions and 17 deletions

View File

@ -1,20 +1,26 @@
const url = "http://localhost/p20/get.php"
let lista
fetch(url)
.then(response => response.json())
.then(data => {
console.log(data)
// console.log(data)
sortujSufiksy(data)
})
function sortujSufiksy() {
const slowo = document.getElementById('slowo').value;
const sufiksy = [];
for (let i = 0; i < slowo.length; i++) {
sufiksy.push(slowo.slice(i));
}
document.getElementById('nieposortowane').textContent = formatSufiksy(sufiksy);
sufiksy.sort();
document.getElementById('posortowane').textContent = formatSufiksy(sufiksy);
function sortujSufiksy(data) {
data.forEach((element) => { console.log(element) });
// 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));
// }
// document.getElementById('nieposortowane').textContent = formatSufiksy(sufiksy);
// sufiksy.sort();
// document.getElementById('posortowane').textContent = formatSufiksy(sufiksy);
}
function formatSufiksy(sufiksy) {

10
get.php
View File

@ -1,12 +1,8 @@
<?php
<<<<<<< HEAD
$dbhost = "qstack.pl";
=======
$dbhost = "localhost";
>>>>>>> PiotrB
$dbuser = "root";
$dbpass = "";
$dbname = "db";
$dbuser = "boost";
$dbpass = "pass";
$dbname = "osoby";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$ans = mysqli_query($conn, "SELECT * FROM osoby");

View File

@ -19,6 +19,10 @@
<pre id="posortowane"></pre>
<script src="fetch.js"></script>
<li id="lista">
<ol></ol>
</li>
</body>
</html>