-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathspells.php
92 lines (70 loc) · 2.06 KB
/
spells.php
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
81
82
83
84
85
86
87
88
89
90
91
92
<style>
td{border-right: 1px solid #dee2e6;text-align: center;}
th{text-align: center !important;}
tr:nth-child(odd){background-color: #efefefa1;}
thead tr:first-child{background-color: #fff;}
</style>
<?php
$config = include 'config.php';
include 'Spell.php';
function getTitle()
{
return 'Büyüler';
}
$spells = file_get_contents("https://www.potterapi.com/v1/spells?key={$config['api_key']}");
$decodedSpells = json_decode($spells, true);
$spellDetails = [];
foreach ($decodedSpells as $decode) {
$spell = new Spell();
$spell->spell = $decode['spell'];
try {
$spell->setType($decode['type']);
} catch (SpellNotFound $exception) {
die($exception->getMessage());
}
$spell->effect = $decode['effect'];
$spellDetails[] = $spell;
// die(var_dump($spellDetails));
}
?>
<?php
include 'header.php';
include 'navbar.php';
?>
<div class="pt-5">
<div class="container">
<section class="jumbotron text-center pt-5 mb-5 bg-white">
<div class="container">
<h1 class="jumbotron-heading"><?php echo getTitle(); ?></h1>
</div>
</section>
<div class="bg-white p-5">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Büyü</th>
<th scope="col">Tür</th>
<th scope="col">Etki</th>
</tr>
</thead>
<tbody>
<?php
$counter = 1;
foreach ($spellDetails as $detail) {
?>
<tr>
<th scope="row"><?php echo $counter++; ?> </th>
<td><?php echo $detail->spell; ?></td>
<td><?php echo $detail->type; ?></td>
<td><?php echo $detail->effect; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<?php
include 'footer.php';
?>