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

10
get.php
View File

@ -1,12 +1,8 @@
<?php <?php
<<<<<<< HEAD
$dbhost = "qstack.pl"; $dbhost = "qstack.pl";
======= $dbuser = "boost";
$dbhost = "localhost"; $dbpass = "pass";
>>>>>>> PiotrB $dbname = "osoby";
$dbuser = "root";
$dbpass = "";
$dbname = "db";
$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");

View File

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