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"; $dbhost = "localhost";
$dbuser = "root"; $dbuser = "root";
$dbpass = ""; $dbpass = "";
$dbname = "osoby"; $dbname = "osdb";
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname); $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$ans = mysqli_query($conn, "SELECT * FROM osoby"); $ans = mysqli_query($conn, "SELECT * FROM osoby");
$json = array(); $json = array();
while ($row = mysqli_fetch_assoc($ans)) { while ($row = mysqli_fetch_assoc($ans)) {
$json[] = $row; $json[] = $row;
} }

32
js.js
View File

@ -1,21 +1,21 @@
const url = "http://localhost/15.05/get.php" const url = "http://localhost/pk/"
fetch( url + 'get.php') fetch( url + 'get.php')
.then(response => response.json()) .then(response => response.json())
.then( data => { .then( data => {
console.log(data) console.log(data)
}) })
function sortujSufiksy() { // function sortujSufiksy() {
const slowo = document.getElementById('slowo').value; // const slowo = document.getElementById('slowo').value;
const sufiksy = []; // const sufiksy = [];
for (let i = 0; i < slowo.length; i++) { // for (let i = 0; i < slowo.length; i++) {
sufiksy.push(slowo.slice(i)); // sufiksy.push(slowo.slice(i));
} // }
document.getElementById('nieposortowane').textContent = formatSufiksy(sufiksy); // document.getElementById('nieposortowane').textContent = formatSufiksy(sufiksy);
sufiksy.sort(); // sufiksy.sort();
document.getElementById('posortowane').textContent = formatSufiksy(sufiksy); // document.getElementById('posortowane').textContent = formatSufiksy(sufiksy);
} // }
function formatSufiksy(sufiksy) { // function formatSufiksy(sufiksy) {
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n'); // return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
} // }