-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalbum.php
More file actions
80 lines (68 loc) · 2.54 KB
/
album.php
File metadata and controls
80 lines (68 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
if (isset($_POST['usu_id'])) {
$usu_id = $_POST['usu_id'];
} else {
$usu_id = 0;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Javascript - Fetch</title>
<style>
body {
background-color: #e6dddd;
}
</style>
</head>
<body>
<div class="container mt-4 shadow-lg p-3 mb-5 bg-body rounded">
<h1> Fetch - Javascript</h1>
<div class=" py-2 bg-light">
<h1 class="p-3">Suggestions</h1>
<div class="container" id="album">
</div>
</div>
<a type="button" href="index.html" target="" rel="noopener noreferrer" class="btn btn-primary mt-2">Volver</a>
</div>
<script>
let url = 'https://jsonplaceholder.typicode.com/albums';
fetch(url)
.then(response => response.json())
.then(data => mostrarData(data))
.catch(error => console.log(error))
const mostrarData = (data) => {
console.log(data)
let body = "";
data.forEach(album => {
body += `
<form action="fotos.php" method="post">
<input type="hidden" name="album_id" value="${album.id}">
<div class="mb-1 p-1 bg-body rounded shadow-sm">
<div class=" text-muted"> Album N°${album.id}
<div class="mb-0 small lh-sm w-100">
<div class="d-flex justify-content-between">
<strong class="text-gray-dark"> Titulo: ${album.title}</strong>
<div>
<button type="submit" class="btn btn-sm btn-outline-primary">Ver</button>
</div>
</div>
</div>
</div>
</div>
</form>
`
});
document.getElementById('album').innerHTML = body
}
</script>
<!-- Bootstrap -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous">
</script>
</body>
</html>