Compare commits

..

4 Commits

Author SHA1 Message Date
pawel d8a7ad5383 fetch 2024-05-20 07:24:17 +02:00
pawel 0cf2d32d88 rob 2024-05-20 07:21:55 +02:00
pawel e2c94ceeb1 poprawione 2024-05-17 10:26:17 +02:00
pawel c9adecf9b0 splot js + db 2024-05-17 10:12:11 +02:00
3 changed files with 13 additions and 4 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;
} }

View File

@ -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
View File

@ -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');
} }