Compare commits
4 Commits
364c6f3ca9
...
d8a7ad5383
Author | SHA1 | Date |
---|---|---|
pawel | d8a7ad5383 | |
pawel | 0cf2d32d88 | |
pawel | e2c94ceeb1 | |
pawel | c9adecf9b0 |
5
get.php
5
get.php
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<pre id="nieposortowane"></pre>
|
<pre id="nieposortowane"></pre>
|
||||||
<h2>Posortowane Sufiksy</h2>
|
<h2>Posortowane Sufiksy</h2>
|
||||||
<pre id="posortowane"></pre>
|
<pre id="posortowane"></pre>
|
||||||
<script src="js.js"></script>
|
<script src="fetch.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
10
js.js
10
js.js
|
@ -1,3 +1,11 @@
|
||||||
|
const url = "http://localhost/pk/"
|
||||||
|
|
||||||
|
fetch( url + 'get.php')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then( data => {
|
||||||
|
console.log(data)
|
||||||
|
})
|
||||||
|
|
||||||
function sortujSufiksy() {
|
function sortujSufiksy() {
|
||||||
const slowo = document.getElementById('slowo').value;
|
const slowo = document.getElementById('slowo').value;
|
||||||
const sufiksy = [];
|
const sufiksy = [];
|
||||||
|
@ -7,7 +15,7 @@ function sortujSufiksy() {
|
||||||
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);
|
||||||
}
|
}git
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue