This commit is contained in:
Your Name 2024-05-15 12:24:25 +02:00
commit 42bd52f9a7
3 changed files with 36 additions and 0 deletions

7
fetch.js Normal file
View File

@ -0,0 +1,7 @@
const url = "http://localhost/15.05/get.php"
fetch( url + 'get.php')
.then(response => response.json())
.then( data => {
console.log(data)
})

16
get.php Normal file
View File

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

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="fetch.js"></script>
</body>
</html>