poprawione

This commit is contained in:
pawel 2024-05-17 10:26:17 +02:00
parent c9adecf9b0
commit e2c94ceeb1
2 changed files with 19 additions and 18 deletions

View File

@ -1,13 +1,14 @@
<?
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "osoby";
$dbname = "osdb";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$ans = mysqli_query($conn, "SELECT * FROM osoby");
$json = array();
while ($row = mysqli_fetch_assoc($ans)) {
$json[] = $row;
}

28
js.js
View File

@ -1,4 +1,4 @@
const url = "http://localhost/15.05/get.php"
const url = "http://localhost/pk/"
fetch( url + 'get.php')
.then(response => response.json())
@ -6,16 +6,16 @@ fetch( url + 'get.php')
console.log(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 formatSufiksy(sufiksy) {
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
}
// 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 formatSufiksy(sufiksy) {
// return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
// }